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

Joe Wang huizhe.wang at oracle.com
Thu Sep 20 00:59:40 UTC 2018

On 9/19/18, 1:52 PM, Brian Burkhalter wrote:
> On Sep 19, 2018, at 1:44 PM, Brian Burkhalter<brian.burkhalter at oracle.com>  wrote:
>> On Sep 19, 2018, at 1:14 PM, Alan Bateman<Alan.Bateman at oracle.com>  wrote:
>>> Starting out using buffered I/O is probably okay but I assume we will want to change this in the future to having it use memory mapped I/O beyond a certain threshold.
>> For the buffered case, could there be any performance advantage to using direct buffers with FileChannel and comparing running checksums of the two sources?
> Don’t think this would work however as two files with differing content could conceivable have the same checksum however likely that might be.

I'll do some performance testing for both cases, FileChannel/direct 
buffer and possible checksum comparison, although, as you said, the 
later might not work since we need to be 100%. The probability of false 
positives is likely extremely low, but is not zero after all. I'll do 
the performance check any ways just out of curiosity. But in many cases, 
checksum comparison may not be faster than direct comparison, esp. in 
this case the API compares just two files. Checksum values would be nice 
if there are multiple files to compare.


> Brian

More information about the core-libs-dev mailing list