Does anybody can help? I can;t see a mistake and in Intelij everything works perfectly.
package pl.codegym.task.task18.task1823;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
/*
Wątki i bajty
*/
public class Solution {
public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
public static List<Integer> listaBajtow = new ArrayList<>();
public static Map<Integer,Integer> listaBajtowIPowtorzen = new LinkedHashMap<>();
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String fileName = "";
while (true){
fileName = scanner.nextLine();
if (fileName.equals("exit"))
break;
else {
ReadThread readThread = new ReadThread(fileName);
}
}
for (Map.Entry<String,Integer> mapka: resultMap.entrySet()){
System.out.println(mapka.getKey() + " " + mapka.getValue());
}
}
public static class ReadThread extends Thread {
private String name="";
public ReadThread(String fileName) {
name = fileName;
start();
}
@Override
public void run() {
try {
FileInputStream fileInputStream = new FileInputStream(name);
int bajt;
while ((bajt= fileInputStream.read())!=-1){
listaBajtow.add(bajt);
}
fileInputStream.close();
for (int i=0;i<listaBajtow.size();i++){
int counter = 0;
for (int j=0;j<listaBajtow.size();j++){
if (listaBajtow.get(i) == listaBajtow.get(j))
counter++;
}
listaBajtowIPowtorzen.put(listaBajtow.get(i),counter);
}
int max = 0;
for (Map.Entry<Integer,Integer> mapcia: listaBajtowIPowtorzen.entrySet()){
if (mapcia.getValue()>max)
max = mapcia.getValue();
}
for (Map.Entry<Integer,Integer> mapcia: listaBajtowIPowtorzen.entrySet()){
if (mapcia.getValue()==max)
resultMap.put(name,mapcia.getKey());
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
}
}