Не могу понять в чем проблема.
package com.javarush.task.task18.task1803;
import java.util.*;
import java.io.*;
/*
Самые частые байты
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
String fileName = scan.nextLine();
ArrayList <Integer> byteList = new ArrayList<>();
FileInputStream fis = new FileInputStream(fileName);
while(fis.available()>0){
byteList.add((Integer)fis.read());
}
fis.close();
Collections.sort(byteList);
int maxCount =1;
Map <Integer, Integer> map = new HashMap<>();
for(int i = 0; i<byteList.size();i++){
int count = 1;
for(int i1 = i+1;i1<byteList.size();i1++){
if(byteList.get(i1).equals(byteList.get(i)))
count++;else if(count>=maxCount){
maxCount=count;
map.put(byteList.get(i), (Integer) count);
i=i1;
break;
}
else{i=i1; break;}
}
}
for(Map.Entry<Integer, Integer>entry : map.entrySet()){
if(entry.getValue().equals((Integer)maxCount))System.out.print(entry.getKey()+" ");
}
}
}