В консоль выводит правильно.
package com.javarush.task.task18.task1803;
/*
Самые частые байты
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<Byte> byteList = new ArrayList<>();
Set<Byte> byteSet = new HashSet<>();
int max = 0;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream fis = new FileInputStream(reader.readLine())) {
while (fis.available() > 0) {
byteList.add((byte) fis.read());
}
} catch (IOException e) {
e.printStackTrace();
}
for (int i = 0; i < byteList.size(); i++) {
for (Byte aByteList : byteList) {
if (aByteList.equals(byteList.get(i))) {
max++;
}
}
if (max > 1) {
byteSet.add(byteList.get(i));
}
max = 0;
}
for (Byte myByte : byteSet) {
System.out.print(myByte + " ");
}
}
}