failing to pass the requirement.
package com.codegym.task.task18.task1821;
import java.io.*;
import java.util.*;
/*
Symbol frequency
1. You don't need to read anything from the console.
2. Create a stream to read from the file passed as the first argument of the main method.
3. You need to calculate the frequency of each symbol in the file and display the results.
4. The displayed results should be sorted by ascending ASCII code.
5. The stream used to read the file must be closed.
*/
public class Solution {
public static void main(String[] args) throws Exception {
String s = args[0];
FileInputStream fis = new FileInputStream(s);
TreeMap<Character, Integer> map = new TreeMap<>();
List<Character> list = new LinkedList<>();
byte[] buffer = new byte[fis.available()];
String v = Arrays.toString(buffer);
char[] h = v.toCharArray();
for (char c : h) {
list.add(c);
}
for (int i = 0; i < list.size(); i++) {
if (map.containsKey(list.get(i))) {
map.replace(list.get(i), map.get(list.get(i)) + 1);
}else {
map.put(list.get(i),1);
}
for (Map.Entry<Character, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey()+ " " + entry.getValue());
}
fis.close();
}
}
}