RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file
huizhe.wang at oracle.com
Fri Apr 27 19:02:50 UTC 2018
On 4/27/2018 4:13 AM, Alan Bateman wrote:
> On 27/04/2018 05:50, Joe Wang wrote:
>> We're looking into adding methods to Files to read a file into a
>> String/write a String to a file. Below is the current proposal.
>> Please review.
>> JBS: https://bugs.openjdk.java.net/browse/JDK-8201276
>> webrev: http://cr.openjdk.java.net/~joehw/jdk11/8201276/webrev/
> The javadoc for these 4 methods looks okay. It might be helpful to
> include something in the readString javadoc to make it absolutely
> clear that the String may include line separators. I assume the "Note
> that .." paragraph can be changed to an @apiNote.
Added a statement to indicate that "the resulting string will contain
line separators as they appear in the file".
Changed the 'note' to @apiNote.
> I assume you'll add "@since 11" to the readString methods.
> It would be good to keep the existing formatting/style consistent with
> the existing code if you can, e.g. <p> tags, 4 space indent rather
> than 8 for the throws, etc.
Fixed <p> and the throws. I didn't even notice that the IDE (NetBeans)
added 8 spaces!
> I can't tell from your mail if you are just looking for feedback on
> the current implementation + tests or just the API. I assume there are
> alternatives to using StringBuilder for the readString methods for
Both. I thought webrevs would be helpful where specdiff was not clear
enough, for example, you won't otherwise notice the formatting/style
I changed that to new String(readAllBytes(path), charset) as it's
convenient with readAllBytes handling all situations (OOM and etc.). But
alternative solution to avoid copying would be nice.
More information about the core-libs-dev