RFR(JDK12/NIO) 8202285: (fs) Add a method to Files for comparing file contents

Joe Wang huizhe.wang at oracle.com
Wed Sep 19 18:48:30 UTC 2018


After much discussion and 10 iterations of reviews, this proposal has 
evolved from what was the original isSameContent method to a mismatch 
method. API-wise, a compare method was also considered as it looked like 
just a short step forward from mismatch, however, it was eventually 
dropped since there is no convincing use case comparing files 
lexicographically by contents. Impl-wise, extensive performance 
benchmarking has been done to compare a buffered reading vs memory 
mapping, the result was that a simple buffered reading performed better 
among small files, and those with the mismatched byte closer to the 
beginning of files. Since the proposed method's targeted files are small 
ones, the impl currently does a buffered reading only.

Please review.

JBS: https://bugs.openjdk.java.net/browse/JDK-8202285


webrev: http://cr.openjdk.java.net/~joehw/jdk12/8202285/webrev/


More information about the core-libs-dev mailing list