😥
package com.javarush.task.task18.task1823;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
/*
Нити и байты
*/
public class Solution {
public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
public static String s = "";
public static void main(String[] args) throws IOException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
while(true) {
s = buffer.readLine();
ReadThread thread = new ReadThread(s);
thread.start();
if(s.equals("exit")) {
break;
}
}
}
public static class ReadThread extends Thread {
private String s;
public ReadThread(String fileName) {
this.s = s;
}
@Override
public void run() {
byte[] sort = new byte [256];
int max = 0;
int maxi = 0;
try( FileInputStream input = new FileInputStream(s)) {
while (input.available() > 0) {
sort[input.read()] += 1;
}
}
catch(IOException e) {
e.printStackTrace();
}
for(int i = 0; i<sort.length; i++) {
if(sort[i]>max) {
max = sort[i];
maxi = i;
}
}
resultMap.put(s,maxi);
}
}
}