Прошу помочь, не пойму где тут:
"Ты выводишь все байты встречающиеся в файле, а нужно только байты с максимальным количеством повторов."
package com.javarush.task.task18.task1803;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;
/*
Самые частые байты
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = reader.readLine();
FileInputStream input = new FileInputStream(fileName);
HashMap<Integer, Integer> map = new HashMap<>();
while (input.available() > 0){
int i = input.read();
if (map.containsKey(i)){
int j = map.get(i);
map.put(i, j++);
} else map.put(i, 1);
}
input.close();
int max = Collections.max(map.values());
for (Map.Entry<Integer, Integer> pair: map.entrySet()){
if (pair.getValue().equals(max)){
byte b = (byte) pair.getKey().intValue();
System.out.printf(b + " ");
}
}
// ArrayList<Integer> keyList = new ArrayList<>(map.keySet());
// ArrayList<Integer> valueList = new ArrayList<>(map.values());
// int max = 1;
// for (int i = 0; i < valueList.size(); i++) {
// if (valueList.get(i) > max) max = valueList.get(i);
// }
// for (int j = 0; j < valueList.size(); j++) {
// if (valueList.get(j) == max) {
// byte b = (byte) keyList.get(j).intValue();
// System.out.print(b + " ");
// }
// }
}
}