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

Joe Wang huizhe.wang at oracle.com
Thu Sep 20 18:08:07 UTC 2018



On 9/20/18, 8:10 AM, Brian Burkhalter wrote:
>
> On Sep 19, 2018, at 5:59 PM, Joe Wang <huizhe.wang at oracle.com 
> <mailto:huizhe.wang at oracle.com>> wrote:
>
>> 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.
>
> I doubt the checksum test is worthwhile. It might be useful however to 
> try FileChannel and direct byte buffers combined with 
> ByteBuffer.mismatch() [1].

Ok, save the time not to run checksum testing :-)  Will do the later, 
actually, I'm almost sure it will be FileChannel/ByteBuffer (better than 
the buffered reading).

Thanks,
Joe

>
> Thanks,
>
> Brian
>
> [1] 
> https://download.java.net/java/early_access/jdk12/docs/api/java.base/java/nio/ByteBuffer.html#mismatch(java.nio.ByteBuffer) 
> <https://download.java.net/java/early_access/jdk12/docs/api/java.base/java/nio/ByteBuffer.html#mismatch%28java.nio.ByteBuffer%29>


More information about the core-libs-dev mailing list