--- old/src/java.base/share/classes/java/nio/file/Files.java 2018-09-18 19:47:11.848369329 -0700 +++ new/src/java.base/share/classes/java/nio/file/Files.java 2018-09-18 19:47:10.958274145 -0700 @@ -91,6 +91,9 @@ */ public final class Files { + // buffer size used for reading and writing + static final int BUFFER_SIZE = 8192; + private Files() { } /** @@ -1530,6 +1533,53 @@ return provider(path).isSameFile(path, path2); } + + /** + * Finds and returns the index of the first mismatched byte in the content + * of two files, or returns -1 if the files are equal. + * + *

Two files are considered equal if they satisfy one of the following + * conditions: + *

+ * + *

Otherwise, there is a mismatch between the two files. This method returns + * a mismatch value, computed as follows: + *

+ * + *

This method may not be atomic with respect to other file system operations. + * + * @param path + * the path to the first file + * @param path2 + * the path to the second file + * + * @return the index of the first mismatch between the two files, or {@code -1} + * if there is no mismatch. + * + * @throws IOException + * if an I/O error occurs, or path or path2 does not exist unless + * they are the same object + * @throws SecurityException + * In the case of the default provider, and a security manager is + * installed, the {@link SecurityManager#checkRead(String) checkRead} + * method is invoked to check read access to both files. + * @since 12 + * + */ + public static long mismatch(Path path, Path path2) throws IOException { + return FilesMismatch.mismatch(path, path2); + } + /** * Tells whether or not a file is considered hidden. The exact * definition of hidden is platform or provider dependent. On UNIX for @@ -2802,8 +2852,6 @@ // -- Utility methods for simple usages -- - // buffer size used for reading and writing - private static final int BUFFER_SIZE = 8192; /** * Opens a file for reading, returning a {@code BufferedReader} that may be