Хочу реализовать с помощью HashSet, но не совсем понимаю как сделать так чтоб первый элемент так же выводися? Можете натолкнутть на правильный путь? Мой код:
package com.javarush.task.task18.task1803;

/*
Самые частые байты
*/

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Solution {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        FileInputStream fileInputStream = new FileInputStream(bf.readLine());
        bf.close();

        int count = fileInputStream.available();

        int[] b = new int[count];
        int index = 0;

        while (fileInputStream.available() > 0) {
            b[index++] = fileInputStream.read();
        }
        fileInputStream.close();

        Map<Integer, Integer> map = new HashMap<>();
        int counter = 1;
        int current = 0;

        for (int i = 0; i < b.length; i++) {
            current = b[i];
            for (int j = 0; j < i; j++) {
                if (current == b[j]) {
                    counter++;
                }
            }
            map.put(current, counter);
            counter = 1;
        }

        map.entrySet().stream().sorted(Map.Entry.<Integer, Integer>comparingByValue().reversed()).limit(3).forEach(Solution::sout); // тут
    }

    public static void sout(Map.Entry<Integer, Integer> i) {
        System.out.print(i.getKey() + " ");
    }
}