Выводит все байты с повторами, но не принимает
package com.javarush.task.task18.task1803;
/*
Самые частые байты
M:\JAVA\test.txt
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
public class Solution {
public static void main(String[] args) throws Exception {
String fileName = new BufferedReader(new InputStreamReader(System.in)).readLine();
FileInputStream fis = new FileInputStream(fileName);
ArrayList<Integer> byteList = new ArrayList<>();
while (fis.available()>0)
{
byteList.add(fis.read());
}
fis.close();
HashMap<Integer,Integer> hm = new HashMap<>();
Integer am;
for(Integer i: byteList){
am = hm.get(i);
hm.put(i, am == null? 1:am+1);
}
int max = Collections.max(hm.values());
System.out.println(hm);
}
}