максимум нахожу а в resultMap не записывает
package com.javarush.task.task18.task1823;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.*;
import java.util.Map;
/*
Нити и байты
*/
public class Solution {
public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
public static String filename;
public static void main(String[] args) throws IOException{
ArrayList<String> lista = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s ;
while ((!(s=reader.readLine()).equals("exit"))){
lista.add(s);
}
for (String element: lista
) {
ReadThread potok = new ReadThread(element);
potok.start();
}
}
public static class ReadThread extends Thread {
public ReadThread(String fileName) throws IOException {
//implement constructor body
Solution.filename = fileName;
}
// implement file reading here - реализуйте чтение из файла тут
@Override
public void run() {
// System.out.println( " Работает run ");
HashMap< Integer, Integer > map = new HashMap<>();
try {
FileInputStream input = new FileInputStream(filename);
byte [] buffer = new byte[input.available()];
input.read(buffer);
input.close();
for (int i = 0; i < buffer.length; i++) {
// System.out.println(buffer[i]); // log
int key = (int) buffer[i];
if(map.size()==0)
map.put(key,1);
else {
if (map.containsKey(key))
{
int count = map.get(key)+1;
map.put(key,count);
}
else {
map.put(key,1);
}
}
}
int max = 0;
int key = -1;
for (Map.Entry<Integer,Integer> paar: map.entrySet()
) {
if (paar.getValue()>max) {
max = paar.getValue();
key = paar.getKey();
}
}
System.out.println(key + ", "+max);
resultMap.put(filename,max);
} catch (Exception e) {
}
}
}
}