Please Help.
package com.codegym.task.task18.task1803;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/*
Most frequent bytes
*/
public class Solution {
public static void main(String[] args) throws Exception {
//Enter a file name from the console
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = reader.readLine();
//Use a FileInputStream to read from the file
FileInputStream inputStream = new FileInputStream(fileName);
ArrayList<Integer>list = new ArrayList<>();
HashMap<Integer,Integer> map = new HashMap<>();
//Find the byte or bytes with the maximum number of repetitions
do{
int i = inputStream.read();
list.add(i);
}while(inputStream.available() > 0);
//The stream used to read the file must be closed
inputStream.close();
for(Integer i:list){
int count = 1;
for (int j = 0; j < list.size() ; j++) {
int a = list.get(i);
if(i != a)
map.put(i,count);
else{
count ++;
map.put(i,count);
}
}
}
//The screen output should be displayed in one line , separated by spaces
int maximum = Integer.MIN_VALUE;
for(Map.Entry<Integer,Integer> pair:map.entrySet()) {
if(pair.getValue() > maximum)
maximum = pair.getValue();
}
for(Map.Entry<Integer,Integer> pair:map.entrySet()) {
if(pair.getValue() == maximum)
System.out.print(pair.getKey() + " ");
}
}
}