RFR: 8029370: (fc) FileChannel javadoc not clear for cases where position == size

Brian Burkhalter bpb at openjdk.org
Fri Feb 24 16:50:04 UTC 2023


On Fri, 24 Feb 2023 16:25:53 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> I thought I checked `transferFrom` but will look again. A CSR was indeed created.

`transferFrom` does not need `or equal to`:

jshell> FileChannel fc = FileChannel.open(Path.of("junk"), StandardOpenOption.READ, StandardOpenOption.WRITE);
fc ==> sun.nio.ch.FileChannelImpl at 528931cf

jshell> FileChannel fc2 = FileChannel.open(Path.of("junk"), StandardOpenOption.READ, StandardOpenOption.WRITE);
fc2 ==> sun.nio.ch.FileChannelImpl at 1563da5

jshell> fc.size()
$5 ==> 83

jshell> fc.transferFrom(fc2, fc.size(), 8)
$6 ==> 8

jshell> fc.size()
$7 ==> 91

jshell> fc.transferFrom(fc2, fc.size() + 1, 8)
$8 ==> 0

jshell> fc.size()
$9 ==> 91

-------------

PR: https://git.openjdk.org/jdk/pull/12735


More information about the nio-dev mailing list