Вроде бы тут четко ищется максимальный байт и мержится в результирующую мапу,
На теста вроде бы все так и есть, Но валидатор не проходит.
for (Integer i : byteList) {
if (Collections.frequency(byteList, i) > max) {
max = i;
resultMap.merge(fileName, i, (oldv, newv) -> i);
}
}
package com.javarush.task.task18.task1823;
import java.io.*;
import java.util.*;
/*
Нити и байты
*/
public class Solution {
public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
public static void main(String[] args) throws FileNotFoundException {
Scanner scanner = new Scanner(System.in);
while (true) {
String fileName = scanner.nextLine();
if (fileName.equals("exit"))
break;
new ReadThread(fileName).start();
}
}
public static class ReadThread extends Thread {
private String fileName;
private List<Integer> byteList;
public ReadThread(String fileName) throws FileNotFoundException {
this.byteList = new ArrayList<>();
this.fileName = fileName;
}
@Override
public void run() {
try {
BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(fileName));
while (inputStream.available() > 0) {
byteList.add(inputStream.read());
}
inputStream.close();
int max = Integer.MIN_VALUE;
for (Integer i : byteList) {
if (Collections.frequency(byteList, i) > max) {
max = i;
resultMap.merge(fileName, i, (oldv, newv) -> i);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}