Можете помочь???
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));
String s = "s";
while (!s.equals("exit")){
s = reader.readLine();
ReadThread thread = new ReadThread(s);
thread.start();
}
}
public static class ReadThread extends Thread {
String fileName;
public ReadThread(String fileName) {
this.fileName = fileName;
// BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(fileName));
// ArrayList<Integer> arr = new ArrayList<>();
// while (inputStream.available() > 0) {
// arr.add(inputStream.read());
// }
// Collections.sort(arr);
// int max = 0;
// for (Integer i : arr) {
// if (Collections.frequency(arr, i) > max) {
// max = Collections.frequency(arr, i);
// }
// }
// for (Integer i : arr) {
// if (Collections.frequency(arr, i) == max) {
// resultMap.put(fileName, i);
// }
// }
//
// inputStream.close();
}
@Override
public void run() {
BufferedInputStream inputStream = null;
try {
inputStream = new BufferedInputStream(new FileInputStream(fileName));
ArrayList<Integer> arr = new ArrayList<>();
while (inputStream.available() > 0) {
arr.add(inputStream.read());
}
Collections.sort(arr);
int max = 0;
for (Integer i : arr) {
if (Collections.frequency(arr, i) > max) {
max = Collections.frequency(arr, i);
}
}
for (Integer i : arr) {
if (Collections.frequency(arr, i) == max) {
resultMap.put(fileName, i);
}
}
} catch (IOException e){
e.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e){
e.printStackTrace();
}
}
}
}
}