Почему не работает?
package com.javarush.task.task18.task1804;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
/*
Самые редкие байты
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String pathFile = bufferedReader.readLine();
readAndAdd(pathFile);
}
public static void readAndAdd(String pathFile) throws Exception {
byte b;
byte[] bytes = new byte[255];
try (FileInputStream fileInputStream = new FileInputStream(pathFile)) {
while (true) {
b = (byte)fileInputStream.read();
if(b == -1) break;
bytes[b]++;
}
}
// remove(bytes);
int min = Integer.MAX_VALUE;
String byteAndReplay = "";
for (int i = 0; i < bytes.length; i++) {
if (bytes[i] != 0) {
min = bytes[i];
for (int j = i + 1; j < bytes.length - i; j++) {
if (bytes[j] != 0 && bytes[j] < min) {
min = bytes[j];
}
}
break;
}
}
for (int j = 0; j < bytes.length; j++) {
if (bytes[j] == min) {
byteAndReplay += j + " ";
}
}
System.out.println(byteAndReplay);
// if (bytes[i] != 0 && bytes[j] != 0) {
// if (bytes[i] < bytes[j]) {
// byteAndReplay += i +
// }
// }
}
// public static void remove(byte[] bytes) {
// ArrayList<Byte> byteArrayList = new ArrayList<>();
// Byte[] byteObject = new Byte[bytes.length];
// int i = 0;
// for (byte b: bytes) {
// byteArrayList.add(byteObject[i++] = b);
// }
// for (int j = 0; j < byteArrayList.size(); j++) {
// if (byteArrayList.get(j) == 0) {
// byteArrayList.remove(j);
// j--;
// }
// }
// System.out.println(byteArrayList);
// }
}
// ArrayList<Byte> byteArrayList = new ArrayList<>();
// try (FileInputStream fileInputStream = new FileInputStream(pathFile)) {
//// while (fileInputStream.available() > 0) {
//// int data = fileInputStream.read();
//// count++;
//// }
// bytes = new byte[6000];
// while (fileInputStream.available() > 0) {
// bytes = fileInputStream.readAllBytes();
// }
// }
// Byte[] byteObject = new Byte[bytes.length];
// int i = 0;
// for (byte b: bytes) {
// byteArrayList.add(byteObject[i++] = b);
// }
// ArrayList<Byte> tempList = new ArrayList<>(byteArrayList);
// System.out.println(tempList);
// tempList.retainAll(byteArrayList);
// System.out.println(tempList);