Class FilesMismatchExamples
java.lang.Object
net.jrodolfo.java_evolution.java12.FilesMismatchExamples
Demonstrates
Files.mismatch(Path, Path), introduced in Java 12.
Before Java 12, finding the first byte where two files differed required manual byte comparison or an external tool. That was too much plumbing for a common diagnostic and testing task.
Files.mismatch solves this by returning -1 when files match
or the first differing byte position when they do not.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongfirstMismatchPosition(Path first, Path second) Finds the first byte position where two files differ.
-
Constructor Details
-
FilesMismatchExamples
public FilesMismatchExamples()
-
-
Method Details
-
firstMismatchPosition
Finds the first byte position where two files differ.- Parameters:
first- the first filesecond- the second file- Returns:
-1when files match, otherwise the first mismatch position- Throws:
IOException- when file access fails
-