:(
package com.javarush.task.task18.task1823;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/*
Нити и байты
*/
public class Solution {
public static Map<String, Integer> resultMap = new HashMap<String, Integer>();
public static Map<Byte, Integer> maxMap = new HashMap<Byte, Integer>();
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<ReadThread> threads = new ArrayList<>();
while(true) {
try {
String file = reader.readLine();
if (file.equals("exit")) {
break;
}
ReadThread thread = new ReadThread(file);
threads.add(thread);
} catch (IOException e) {}
}
for (ReadThread thread : threads) {
thread.start();
}
}
public static class ReadThread extends Thread {
private String filename;
public ReadThread(String fileName) {
this.filename = fileName;
}
@Override
public void run() {
try {
int count = 0;
FileInputStream inputStream = new FileInputStream(filename);
byte[] buffer = new byte[inputStream.available()];
byte[] buffer1 = new byte[inputStream.available()];
while (inputStream.available() > 0) {
int data = inputStream.read(buffer);
int data1 = inputStream.read(buffer1);
inputStream.close();
}
for (int x = 0; x < buffer.length; x++) {
for(int y = 0; y < buffer1.length; y++) {
if (buffer[x] == buffer1[y]) {
count++;
}
}
maxMap.put(buffer[x], count);
}
byte maxVal = 0;
int max = -1;
for (Map.Entry<Byte, Integer> me : maxMap.entrySet()) {
if(me.getValue() > max) {
max = me.getValue();
maxVal = me.getKey();
}
}
resultMap.put(filename, (int) maxVal);
} catch (Exception e) {}
}
}
}