I'm trying to build a custom FileChannel
, and I'm experiencing a lack of clarity due to inconsistency in the documentation.
The documentation for the FileChannel.transferFrom(ReadableByteChannel src, long position, long count)
method says,
If the given position is greater than the file's current size then no bytes are transferred.
Now, shouldn't they have said this instead? :
"If
position + count
is greater than file's current size then no bytes are transferred."
The reason I suspect this may be a bug in the documentation is this. Elsewhere in the same API doc, if the file needs to grow, an explicit mention of it is made, as in the case of FileChannel.write(ByteBuffer src, long position)
:
"If the given position is greater than the file's current size then the file will be grown to accommodate the new bytes;"
So, if no mention has been made of any file growth in case of FileChannel.transferFrom()
, I get the impression that file is not supposed to grow via this method. But the problem is, the file can grow not only "If the given position is greater than the file's current size" but also "if position + count
is greater than file's current size".