Class ByteBufferReadableClosingFSDataInputStream

    • Method Detail

      • read

        public int read​(ByteBuffer byteBuffer)
                 throws IOException
        Description copied from interface: ByteBufferReadable
        Reads up to byteBuffer.remaining() bytes into byteBuffer. Callers should use byteBuffer.limit(..) to control the size of the desired read.

        After a successful call, byteBuffer.position() will be advanced by the number of bytes read and byteBuffer.limit() should be unchanged.

        In the case of an exception, the values of byteBuffer.position() and byteBuffer.limit() are undefined, and callers should be prepared to recover from this eventuality. Implementations should treat 0-length requests as legitimate, and must not signal an error upon their receipt.

        Specified by:
        read in interface ByteBufferReadable
        Parameters:
        byteBuffer - the ByteBuffer to receive the results of the read operation.
        Returns:
        the number of bytes read, possibly zero, or -1 if reach end-of-stream
        Throws:
        IOException - if there is some error performing the read
      • read

        public int read​(long position,
                        ByteBuffer byteBuffer)
                 throws IOException
        Description copied from interface: ByteBufferReadable
        Reads up to byteBuffer.remaining() bytes into byteBuffer from a given position in the file and returns the number of bytes read. Callers should use byteBuffer.limit(...) to control the size of the desired read and byteBuffer.position(...) to control the offset into the buffer the data should be written to.

        After a successful call, byteBuffer.position() will be advanced by the number of bytes read and byteBuffer.limit() will be unchanged.

        In the case of an exception, the state of the buffer (the contents of the buffer, the buf.position(), the buf.limit(), etc.) is undefined, and callers should be prepared to recover from this eventuality.

        Implementations should treat 0-length requests as legitimate, and must not signal an error upon their receipt.

        Specified by:
        read in interface ByteBufferReadable
        Parameters:
        position - position within file
        byteBuffer - the ByteBuffer to receive the results of the read operation.
        Returns:
        the number of bytes read, possibly zero, or -1 if reached end-of-stream
        Throws:
        IOException - if there is some error performing the read