Class RandomAccessFileInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class RandomAccessFileInputStream
    extends java.io.InputStream
    Streams data from a RandomAccessFile starting at its current position.
    Since:
    2.8.0
    • Constructor Summary

      Constructors 
      Constructor Description
      RandomAccessFileInputStream​(java.io.RandomAccessFile file)
      Constructs a new instance configured to leave the underlying file open when this stream is closed.
      RandomAccessFileInputStream​(java.io.RandomAccessFile file, boolean closeOnClose)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream.
      long availableLong()
      Returns the number of bytes that can be read (or skipped over) from this input stream.
      void close()  
      java.io.RandomAccessFile getRandomAccessFile()
      Gets the underlying file.
      boolean isCloseOnClose()
      Returns whether to close the underlying file when this stream is closed.
      int read()  
      int read​(byte[] bytes)  
      int read​(byte[] bytes, int offset, int length)  
      long skip​(long skipCount)  
      • Methods inherited from class java.io.InputStream

        mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, transferTo
      • Methods inherited from class java.lang.Object

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

      • RandomAccessFileInputStream

        public RandomAccessFileInputStream​(java.io.RandomAccessFile file)
        Constructs a new instance configured to leave the underlying file open when this stream is closed.
        Parameters:
        file - The file to stream.
      • RandomAccessFileInputStream

        public RandomAccessFileInputStream​(java.io.RandomAccessFile file,
                                           boolean closeOnClose)
        Constructs a new instance.
        Parameters:
        file - The file to stream.
        closeOnClose - Whether to close the underlying file when this stream is closed.
    • Method Detail

      • available

        public int available()
                      throws java.io.IOException
        Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream. If there are more than Integer.MAX_VALUE bytes available, return Integer.MAX_VALUE.
        Overrides:
        available in class java.io.InputStream
        Returns:
        An estimate of the number of bytes that can be read.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • availableLong

        public long availableLong()
                           throws java.io.IOException
        Returns the number of bytes that can be read (or skipped over) from this input stream.
        Returns:
        The number of bytes that can be read.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • getRandomAccessFile

        public java.io.RandomAccessFile getRandomAccessFile()
        Gets the underlying file.
        Returns:
        the underlying file.
      • isCloseOnClose

        public boolean isCloseOnClose()
        Returns whether to close the underlying file when this stream is closed.
        Returns:
        Whether to close the underlying file when this stream is closed.
      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] bytes)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] bytes,
                        int offset,
                        int length)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • skip

        public long skip​(long skipCount)
                  throws java.io.IOException
        Overrides:
        skip in class java.io.InputStream
        Throws:
        java.io.IOException