Подскажите, что не так, вроде тестирую и все работает как надо.
package com.javarush.task.task18.task1823;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/*
Нити и байты
*/
public class Solution {
public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = null;
while (!(fileName = reader.readLine()).equals("exit")) {
new Thread(new ReadThread(fileName)).start();
}
for (Map.Entry<String, Integer> pair : resultMap.entrySet()) {
System.out.println(pair.getKey() + " " + pair.getValue());
}
reader.close();
}
public static class ReadThread extends Thread {
private String fileName;
public ReadThread(String fileName) {
this.fileName = fileName;
}
@Override
public void run() {
int[] ints = new int[256];
try (FileInputStream fis = new FileInputStream(fileName)){
while (fis.available()>0) {
int bytes = fis.read();
ints[bytes] = ints[bytes] + 1;
}
// ищем макс встречающийся байт
int count=0;
int tmpIndex=0;
for (int i = 0; i < ints.length; i++) {
int tmp=ints[i];
if (tmp>tmpIndex){
tmpIndex=tmp;
count=i;
}
}
Arrays.sort(ints);
int i = ints[ints.length-1];
resultMap.put(Paths.get(fileName).getFileName().toString(), count);
}
catch (IOException e){
e.printStackTrace();
}
}
}
}