Two issues in Files

Colin Decker cgdecker at google.com
Wed Sep 11 14:36:23 PDT 2013


Hi,
I noticed a couple of small issues in Files for JDK8.

The first, more significant issue, is that Files.readAllBytes(Path) now
creates a FileChannel, while FileSystemProvider implementations are not
required to support FileChannel. A SeekableByteChannel could be created
instead, and at least seems much more likely to be supported than
FileChannel.

The second issue is with Files.write(Path, byte[], OpenOption...). Instead
of passing the whole input byte array to OutputStream.write(byte[]), thus
allowing the OutputStream implementation to decide how best to handle it,
it loops through writing 8k slices of the array to the OutputStream. Is
this intended? It seems wasteful, particularly if an implementation (such
as an in-memory implementation) could just write the whole array at once
(and might even benefit from knowing up front the total number of bytes
being written.)

Thanks,
Colin

-- 
Colin Decker | Software Engineer | cgdecker at google.com | Java Core
Libraries Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20130911/8fb623db/attachment.html 


More information about the nio-dev mailing list