8019526: (fs) Files.lines, etc without Charset parameter
Paul Sandoz
paul.sandoz at oracle.com
Fri Oct 11 08:02:10 PDT 2013
Change to Files looks good.
I did not look too closely at the changes to the test files, just focused on the areas where UTF-8 is the default.
Paul.
On Oct 11, 2013, at 4:46 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>
> The Files class defines a number of very useful methods to operate on text files, all of which take a Charset parameter for the charset to use when encoding or decoding. It's come many times that folks want variants of these that don't have to specify the Charset. Additionally we now have Files.lines, added as part of the Lambda libraries work, and a variant without the Charset parameter is required to use method references.
>
> The proposal here is to define variants of each of these methods that use UTF-8 for encoding and decoding instead of taking a Charset parameter. The rational for UTF-8 is that methods that use the default charset are always problematic. With many platforms using UTF-8 now then it is less of an issue from a few years ago but still problematic due to the dependency on the locale. The proposal does mean an inconsistency with the legacy APIs but it should only be an issue if there is mixing of APIs without due consideration. Going forward then it may actually be time to consider changing the JDK's default charset to UTF-8 (I'm not suggesting this for JDK 8 of course, that is a mich bigger issue than what is proposed here and would require deeper consideration).
>
> The webrev with the proposed changes is here. The updates to the Files class are trivial (one-liner methods), most of the changes are in the tests. I've expanding Henry's StreamTest to exercise Files.lines(Path) and also converted the BytesAndLines to TestNG. More could be done on the BytesAndLines but it's not critical for this patch.
>
> http://cr.openjdk.java.net/~alanb/8019526/webrev/
>
> Thanks,
> Alan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20131011/25a1344d/signature.asc
More information about the nio-dev
mailing list