Does someone perhaps know why my solution fails the validation?
the outputs seem to be correct when I test with sample file...
package com.codegym.task.task18.task1804;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
/*
Rarest bytes
Enter a file name from the console.
Find the byte or bytes with the minimum number of repetitions.
Display them on the screen, separated by spaces.
Close the IO stream.
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file = reader.readLine();
FileInputStream fileInputStream = new FileInputStream(file);
Map<Integer,Integer> map = new HashMap<>(fileInputStream.available());
int minCount = fileInputStream.available();
while (fileInputStream.available() > 0) {
int thisByte = fileInputStream.read();
//System.out.println(thisByte);
map.merge(thisByte, 1, Integer::sum);
if (map.get(thisByte) < minCount) minCount = map.get(thisByte);
}
fileInputStream.close();
for (Map.Entry<Integer, Integer> pair : map.entrySet()) {
if (pair.getValue() == minCount)
System.out.print(pair.getKey() + " ");
}
}
}