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

Joe Wang huizhe.wang at oracle.com
Mon Apr 30 23:19:28 UTC 2018


First, this is intended to be an extension to the existing isSameFile 
method since it stopped short of comparing the content to answer the 
query for whether two files are equal.

We did a review/a bit of research on user demand. Comparing files isn't 
as high as for example readString, but there's a fair number of people 
who were interested in determining if two files have the same content. 
It would be nice if you could point us the evidence on comparing a file 
against a batch of other files as being the usual use case.

Comparing one against many, hashing would be more efficient. Between two 
files, byte-by-byte would be the error (albeit tiny chance) free choice.

Thanks,
Joe

On 4/27/2018 4:37 AM, Remi Forax wrote:
> This seems to promote the wrong way to do such thing,
> the usual use case is that you want to compare the content of a well know file with the content of a bunch of other files, so hashing is better.
>
> Rémi
>
> ----- Mail original -----
>> De: "Joe Wang" <huizhe.wang at oracle.com>
>> À: "nio-dev" <nio-dev at openjdk.java.net>, "core-libs-dev" <core-libs-dev at openjdk.java.net>
>> Envoyé: Vendredi 27 Avril 2018 06:51:08
>> Objet: RFR(JDK11/NIO) 8202285: (fs) Add a method to Files for comparing file contents
>> Hi,
>>
>> Considering extending isSameFile to add isSameContent to Files. Please
>> review.
>>
>> JBS: https://bugs.openjdk.java.net/browse/JDK-8202285
>>
>> webrev: http://cr.openjdk.java.net/~joehw/jdk11/8202285/webrev/
>>
>> specdiff:
>> http://cr.openjdk.java.net/~joehw/jdk11/8202285/specdiff/java/nio/file/Files.html
>>
>> Thanks,
>> Joe



More information about the core-libs-dev mailing list