Is there any problem with the for loop?
package com.codegym.task.task18.task1821;
/*
Symbol frequency
*/
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class Solution {
public static void main(String[] args) throws IOException {
FileInputStream fileInputStream = new FileInputStream(args[0]);
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read();
fileInputStream.close();
String string = new String(bytes);
char[] chars = string.toCharArray();
int count = 0;
Map<Character, Integer> map = new TreeMap<>();
for (char schar : chars) {
if (!(map.containsKey(schar))){
for (char schar2 : chars){
if (schar == schar2)
count++;
}
map.put(schar, count);
count = 0;
}
}
for (Map.Entry<Character, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey() + " " + entry.getValue());
}
}
}