Exactly what FileUtils.contentEquals
method of Apache commons IO does and api is here.
Try something like:
File file1 = new File("file1.txt");
File file2 = new File("file2.txt");
boolean isTwoEqual = FileUtils.contentEquals(file1, file2);
It does the following checks before actually doing the comparison:
- existence of both the files
- Both file's that are passed are to be of file type and not directory.
- length in bytes should not be the same.
- Both are different files and not one and the same.
- Then compare the contents.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…