This question has already been asked 7 years ago but I can't add answers anymore because it's [closed].
So this is not a question - this is a solution suggestion : Since Java 1.7 this can be a one liner:
public class FilesComparator {
public static boolean filesEquals(Path f1, Path f2) throws IOException {
return Arrays.equals(Files.readAllBytes(f1), Files.readAllBytes(f2));
}
}