вроде бы все корректно , но чтото не нравится ему. что?
package com.javarush.task.task18.task1823;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class Solution {
public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
public static String name;
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader( new InputStreamReader( System.in));
while (true){
name = reader.readLine();
if (name.equals("exit")){
reader.close();
break;}
new ReadThread(name).start();
}
}
public static class ReadThread extends Thread {
public static InputStream inputStream;
Map<Integer,Integer> map = new HashMap<>();
public String fn;
public ReadThread(String fileName) throws IOException{
fn=fileName;
inputStream = new FileInputStream(fileName);
}
public void run() {
while (true){
try {
if (!(inputStream.available()>0)) break;
int a =inputStream.read();
if(map.containsKey(a)){
map.put(a,(map.get(a)+1));
}
else {
map.putIfAbsent(a,1);
}
} catch (IOException e) {
e.printStackTrace();
}
}
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
int max=-1;
int key=-1;
for (Map.Entry<Integer,Integer> it:map.entrySet()) {
if(it.getValue()>max){
max=it.getValue();
key=it.getKey();
}
}
synchronized (Solution.class){
resultMap.put(fn,key);}
}
}
}