Discuss please this one , I think I am right conclusion.
package com.codegym.task.task18.task1803;
import java.io.FileInputStream;
import java.util.*;
/*
Most frequent bytes
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner in = new Scanner(System.in);
String filename = in.nextLine();
FileInputStream fis = new FileInputStream(filename);
ArrayList<Integer> allBytes = new ArrayList<>();
while (fis.available() > 0){
int data = fis.read();
allBytes.add(data);
}
in.close();
fis.close();
Collections.sort(allBytes);
Map<Integer , Integer> map = new HashMap<>();
int countValue = 0;
for (int i =0 ; i < allBytes.size() ; i++){
int value = allBytes.get(i);
for (int j = 1 ; j < allBytes.size() ; j++){
int value2 = allBytes.get(j);
if (value == value2){
map.put(value , countValue++);
}
else
countValue = 0;
}
}
int max = map.get(0);
for (Integer i : map.values()){
if (i > max){
max = i;
}
}
System.out.println(max);
}
}