RFR(JDK11/NIO) 8202285: (fs) Add a method to Files for comparing file contents (original) (raw)
Joe Wang huizhe.wang at oracle.com
Tue May 1 00:04:55 UTC 2018
- Next message: RFR(JDK11/NIO) 8202285: (fs) Add a method to Files for comparing file contents
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Good point. So even if we go with "has" (instead of "is"), it'd be hasSameContent, semantically, it would be "has the same content".
-Joe
On 4/30/2018 4:10 PM, Jonathan Gibbons wrote:
At the risk of triggering a #bikeshed on the relative merits of "content" vs. "contents", I note that String has put a stake in the ground for the singular form, with contentEquals.
-- Jon On 4/30/18 4:02 PM, Joe Wang wrote: Hi Jonathan,
hasSameContents does read better in English. This one was made isSameContent since I thought we'd want to stack it next to the existing isSameFile method since it's meant to be an extend to that method. I'd love to hear what people think about this. I'm open to change the name if there's a good consensus. Cheers, Joe On 4/27/2018 4:01 AM, Jonathan Bluett-Duncan wrote: Hi Joe,
I wonder if the method
isSameContent
should be namedhaveSameContents
so as to read more fluently in English. Cheers, Jonathan On 27 April 2018 at 11:58, Daniel Fuchs <daniel.fuchs at oracle.com_ _<mailto:daniel.fuchs at oracle.com>> wrote: Hi Joe, On the specification side, I think I would reword the API documentation to first explain how the method checks the content of the two files. The fact that it doesn't check the actual content if the two files are 'the same' is kind of an optimization. So I would suggest to invert the order of the two paragraph in the documentation, and combine them into one - something like: 1536 * * This method first calls {@link #isSameFile(java.nio.file.Path, java.nio.file.Path) isSameFile(path, path2)} to determine whether the two files are the same. 1537 * If {@code isSameFile(path, path2)} returns false, this method will proceed 1538 * to read the files and compare them byte by byte to determine if they contain 1539 * the same contents. * Otherwise, this method will return true without further * processing.On the implementation side I don't think it's reasonable to call readAllBytes() and hold the content of the two files in memory for comparing their content, especially if it's to discover that the first byte differs. Some lock-step reading of the two files would seem more appropriate. best regards, -- daniel
On 27/04/2018 05:51, Joe Wang wrote: Hi, Considering extending isSameFile to add isSameContent to Files. Please review. JBS: https://bugs.openjdk.java.net/browse/JDK-8202285 <https://bugs.openjdk.java.net/browse/JDK-8202285> webrev: http://cr.openjdk.java.net/~joehw/jdk11/8202285/webrev/ <http://cr.openjdk.java.net/%7Ejoehw/jdk11/8202285/webrev/> specdiff: http://cr.openjdk.java.net/~joehw/jdk11/8202285/specdiff/java/nio/file/Files.html <http://cr.openjdk.java.net/%7Ejoehw/jdk11/8202285/specdiff/java/nio/file/Files.html> Thanks, Joe
- Next message: RFR(JDK11/NIO) 8202285: (fs) Add a method to Files for comparing file contents
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]