Testing the code on my computer with different inputs I always get correct output, but when I submit it I get this error. Someone can see my error?
package com.codegym.task.task18.task1821;
/*
Symbol frequency
*/
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<Byte> list = new ArrayList<>();
FileInputStream reader = new FileInputStream(args[0]);
Map<Character, Integer> map = new TreeMap<>();
char ch = ' ';
char ch1 = ' ';
int count = 0;
// Adding all symbols in the list
while (reader.available() > 0) {
list.add((byte) reader.read());
}
reader.close();
// Comparing every symbol with all other symbols in the list
// and counting his appearances in the list.
for (int i = 0; i < list.size(); i++) {
byte be = list.get(i);
ch = (char) be;
for (int k = 0; k < list.size(); k++) {
byte bt = list.get(k);
ch1 = (char) bt;
if (ch1 == ch) {
count++;
}
}
// TreeMap naturally sorts the symbols in ascending order
map.put(ch, count);
count = 0;
}
// Printing the results in ascending ASCII order with the number of appearances
for (Map.Entry<Character, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey() + " " + entry.getValue());
}
}
}