Похоже проблема в сортировке. Прошу помощи
package com.javarush.task.task18.task1821;
import java.io.*;
import java.util.*;
/*
Встречаемость символов
*/
public class Solution {
public static void main(String[] args)throws FileNotFoundException, IOException {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(args[0]));
ArrayList<Byte> list = new ArrayList<>();
Map<Byte, Integer> map = new TreeMap<>();
if(bis.available() > 0)
list.add((byte) bis.read());
Collections.sort(list);
bis.close();
int k = 0;
for(int i = 0; i < list.size(); i++){
k = Collections.frequency(list, list.get(i));
map.put(list.get(i), k);
}
for(Map.Entry <Byte,Integer> pair: map.entrySet()){
byte b = pair.getKey();
char c = (char) b;
System.out.print(c + " " + pair.getValue());
}
}
}