Class SeekableStream

    • Field Detail

    • Constructor Detail

      • SeekableStream

        public SeekableStream()
    • Method Detail

      • length

        public abstract long length()
        Returns:
        the length of the stream; 0 if not available or empty.
      • position

        public abstract long position()
                               throws IOException
        Returns:
        the current byte position of the stream.
        Throws:
        IOException
      • seek

        public abstract void seek​(long position)
                           throws IOException
        Seeks the stream to the provided position.
        Throws:
        IOException
      • eof

        public abstract boolean eof()
                             throws IOException
        Returns:
        true if the stream is already consumed; false otherwise.
        Throws:
        IOException
      • getSource

        public abstract String getSource()
        Returns:
        String representation of source (e.g. URL, file path, etc.), or null if not available.
      • readFully

        public void readFully​(byte[] b)
                       throws IOException
        Read enough bytes to fill the input buffer.
        Parameters:
        b -
        Throws:
        EOFException - If EOF is reached before buffer is filled
        IOException
      • available

        public int available()
                      throws IOException
        The return value of this method is unusable for any purpose, and we are only implementing it because certain Java classes like GZIPInputStream incorrectly rely on it to detect EOF

        If eof() == true, 0 bytes are available. Otherwise, available bytes are the difference between the length of the stream (length()) and the current position (position().

        Overrides:
        available in class InputStream
        Returns:
        0 if the end of the file has been reached or the length cannot be determined; number of bytes remaining in the stream otherwise.
        Throws:
        IOException
      • mark

        public final void mark​(int readlimit)
        Mark the current position of the stream.

        Note: there is no limit for reading.

        Overrides:
        mark in class InputStream
        Parameters:
        readlimit - ignored.
        Throws:
        RuntimeIOException - if an IO error occurs other than an already closed stream.