Class LocalDataInputStream

    • Constructor Detail

      • LocalDataInputStream

        public LocalDataInputStream​(File file)
                             throws IOException
        Constructs a new LocalDataInputStream object from a given File object.
        Parameters:
        file - The File the data stream is read from
        Throws:
        IOException - Thrown if the data input stream cannot be created.
    • Method Detail

      • seek

        public void seek​(long desired)
                  throws IOException
        Description copied from class: FSDataInputStream
        Seek to the given offset from the start of the file. The next read() will be from that location. Can't seek past the end of the stream.
        Specified by:
        seek in class FSDataInputStream
        Parameters:
        desired - the desired offset
        Throws:
        IOException - Thrown if an error occurred while seeking inside the input stream.
      • getPos

        public long getPos()
                    throws IOException
        Description copied from class: FSDataInputStream
        Gets the current position in the input stream.
        Specified by:
        getPos in class FSDataInputStream
        Returns:
        current position in the input stream
        Throws:
        IOException - Thrown if an I/O error occurred in the underlying stream implementation while accessing the stream's position.
      • 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