@InterfaceAudience.Public @InterfaceStability.Evolving public interface ByteBufferPositionedReadable
ByteBufferrather than a
int read(long position, ByteBuffer buf) throws IOException
buf.remaining()bytes into buf from a given position in the file and returns the number of bytes read. Callers should use
buf.limit(...)to control the size of the desired read and
buf.position(...)to control the offset into the buffer the data should be written to.
After a successful call,
buf.position() will be advanced by the
number of bytes read and
buf.limit() will be unchanged.
In the case of an exception, the state of the buffer (the contents of the
buf.limit(), etc.) is
undefined, and callers should be prepared to recover from this eventuality.
Callers should use
StreamCapabilities.PREADBYTEBUFFER to check if the underlying
stream supports this interface, otherwise they might get a
Implementations should treat 0-length requests as legitimate, and must not signal an error upon their receipt.
position- position within file
buf- the ByteBuffer to receive the results of the read operation.
IOException- if there is some error performing the read
Copyright © 2022 Apache Software Foundation. All rights reserved.