Class FileRandomIO

    • Field Detail

      • bufferSize

        protected int bufferSize
      • offset

        protected long offset
    • Constructor Detail

      • FileRandomIO

        public FileRandomIO​(RandomAccessFile file)
        Behave like FileRandomIO(file, DEFAULT_BUFFER_SIZE)
        Parameters:
        file - local file that will be be used as data source or destination
      • FileRandomIO

        public FileRandomIO​(RandomAccessFile file,
                            int bufferSize)
        Parameters:
        file - local file that will be be used as data source or destination
        bufferSize - size of the buffer returned during single read operation
    • Method Detail

      • write

        public void write​(Buffer buffer)
                   throws IOException
        Description copied from interface: DataSink
        Writes the specified buffer to this data sink.
        Note: buffer.getOffset() might return -1 if the transfer mode used does not support data offsets, for example stream transfer mode.
        Specified by:
        write in interface DataSink
        Parameters:
        buffer - the data buffer to write.
        Throws:
        IOException - if an I/O error occurs.
      • read

        public Buffer read()
                    throws IOException
        In this implementation, each read() returns data sequentially.
        Specified by:
        read in interface DataSource
        Returns:
        The data buffer read. Null, if there is no more data to be read.
        Throws:
        IOException - if an I/O error occurs.
      • totalSize

        public long totalSize()
                       throws IOException
        Description copied from interface: DataSource
        Optional operation. Returns the total size, in bytes, of the data in this source. If the implementation is not able to provide a total size for the data source, it should return -1
        Specified by:
        totalSize in interface DataSource
        Throws:
        IOException - if an I/O exception occurs