Class SeekableReadOnlyFile

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.RandomAccessFile file  
    • Constructor Summary

      Constructors 
      Constructor Description
      SeekableReadOnlyFile​(java.io.File file)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close this channel.
      long getPosition()  
      int read()
      Read a single byte of data.
      int read​(byte[] buffer, int off, int count)
      Read up to count bytes to the specified buffer.
      int readFully​(byte[] buffer, int count)
      Read exactly count bytes to the specified buffer.
      void setPosition​(long pos)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • file

        private final java.io.RandomAccessFile file
    • Constructor Detail

      • SeekableReadOnlyFile

        public SeekableReadOnlyFile​(java.io.File file)
                             throws java.io.FileNotFoundException
        Parameters:
        file - the file
        Throws:
        java.io.FileNotFoundException - .
    • Method Detail

      • readFully

        public int readFully​(byte[] buffer,
                             int count)
                      throws java.io.IOException
        Description copied from interface: SeekableReadOnlyByteChannel
        Read exactly count bytes to the specified buffer.
        Specified by:
        readFully in interface SeekableReadOnlyByteChannel
        Parameters:
        buffer - where to store the read data
        count - how many bytes to read
        Returns:
        bytes read || -1 if IO problem
        Throws:
        java.io.IOException - .
      • getPosition

        public long getPosition()
                         throws java.io.IOException
        Specified by:
        getPosition in interface SeekableReadOnlyByteChannel
        Returns:
        the current position in the channel
        Throws:
        java.io.IOException - .
      • setPosition

        public void setPosition​(long pos)
                         throws java.io.IOException
        Specified by:
        setPosition in interface SeekableReadOnlyByteChannel
        Parameters:
        pos - the position in the channel
        Throws:
        java.io.IOException - .
      • read

        public int read​(byte[] buffer,
                        int off,
                        int count)
                 throws java.io.IOException
        Description copied from interface: SeekableReadOnlyByteChannel
        Read up to count bytes to the specified buffer.
        Specified by:
        read in interface SeekableReadOnlyByteChannel
        Parameters:
        buffer - .
        off - .
        count - .
        Returns:
        read read
        Throws:
        java.io.IOException - .