As far as I understand the task condition, I'm doing exactly as what is wanted, but still can't pass that 3rd condition. I think I'm missing the output, but still can't figure it out. Any advice....Lupe? :D
package com.codegym.task.task18.task1803;
import java.io.FileInputStream;
import java.util.*;
/*
Most frequent bytes
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
//"D:\\codegym_read_text.txt"
FileInputStream fileInputStream = new FileInputStream(scan.nextLine());
int counter = 0;
int tempCount = 0;
List<Integer> allBytes = new ArrayList<Integer>();
List<Integer> bytesPassed = new ArrayList<Integer>();
while(fileInputStream.available() > 0){
allBytes.add(fileInputStream.read());
}
Collections.sort(allBytes);
for (int i = 0; i < allBytes.size(); i++) {
for (int j = 0; j < allBytes.size(); j++) {
if(allBytes.get(i) == allBytes.get(j)){
counter++;
}
}
if(counter > 1){
if(!bytesPassed.contains(allBytes.get(i))) {
bytesPassed.add(allBytes.get(i));
System.out.print(allBytes.get(i) + " ");
}
}
counter = 0;
}
scan.close();
fileInputStream.close();
}
}