Все работает и добавляется но по 4 пункту не проходит
package com.javarush.task.task18.task1823;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
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));
ArrayList<String> files = new ArrayList<>();
while (true) {
String file = reader.readLine();
if (file.equals("exit")) {
break;
}
ReadThread thread = new ReadThread(file);
}
}
public static class ReadThread extends Thread {
private static String filename;
int theByte;
int count;
public ReadThread(String fileName) throws FileNotFoundException {
//implement constructor body
this.filename = fileName;
start();
}
// implement file reading here - реализуйте чтение из файла тут
public void run() {
try {
FileInputStream inputStream = new FileInputStream(filename);
ArrayList<Integer> bytes = new ArrayList<>();
while (inputStream.available() > 0) {
bytes.add(inputStream.read());
}
int a = 0;
for (int i = 0; i < bytes.size(); i++) {
count = Collections.frequency(bytes, bytes.get(i));
if (count > a) {
theByte = i;
}
}
synchronized (resultMap){
resultMap.put(filename, bytes.get(theByte));
}
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}