Created
October 9, 2021 14:17
-
-
Save nowshad-hasan/8cddc4006573605de8de855dec8a4e24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FileMismatchExample { | |
/* | |
Here, hello1 and hello3 have same content, hello2 has different content. | |
*/ | |
public static void main(String[] args) { | |
Path path1 = Path.of("hello1.txt"); | |
Path path2 = Path.of("hello2.txt"); | |
Path path3 = Path.of("hello3.txt"); | |
try { | |
System.out.println(Files.mismatch(path1, path1)); // -1, as same file comparison | |
System.out.println(Files.mismatch(path1, path2)); // 13, different files, different content | |
System.out.println(Files.mismatch(path1, path3)); // -1, as same content | |
System.out.println(Files.mismatch(path2, path3)); // 13, different files, different content | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment