Class RandomAccessInputStream

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

    public final class RandomAccessInputStream
    extends java.io.InputStream
    This is a class that uses a memory cache to allow seeking within an InputStream. Based on the JAI MemoryCacheSeekableStream class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int BLOCK_MASK  
      private static int BLOCK_SHIFT  
      private static int BLOCK_SIZE  
      private java.util.Vector data  
      private boolean foundEOS  
      private long length  
      private long pointer  
      private java.io.InputStream src  
    • Constructor Summary

      Constructors 
      Constructor Description
      RandomAccessInputStream​(java.io.InputStream inputstream)
      Constructs a RandomAccessStream from an InputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      int getFilePointer()  
      long getLongFilePointer()  
      int read()  
      int read​(byte[] bytes, int off, int len)  
      double readDouble()  
      float readFloat()  
      void readFully​(byte[] bytes)  
      void readFully​(byte[] bytes, int len)  
      int readInt()  
      long readLong()  
      short readShort()  
      private long readUntil​(long l)  
      void seek​(int loc)  
      void seek​(long loc)  
      • Methods inherited from class java.io.InputStream

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

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

      • src

        private final java.io.InputStream src
      • pointer

        private long pointer
      • data

        private final java.util.Vector data
      • length

        private long length
      • foundEOS

        private boolean foundEOS
    • Constructor Detail

      • RandomAccessInputStream

        public RandomAccessInputStream​(java.io.InputStream inputstream)
        Constructs a RandomAccessStream from an InputStream. Seeking backwards is supported using a memory cache.
        Parameters:
        inputstream - .
    • Method Detail

      • getFilePointer

        public int getFilePointer()
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • getLongFilePointer

        public long getLongFilePointer()
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • 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,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • readFully

        public void readFully​(byte[] bytes)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • readFully

        public void readFully​(byte[] bytes,
                              int len)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • readUntil

        private long readUntil​(long l)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • seek

        public void seek​(long loc)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • seek

        public void seek​(int loc)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readInt

        public int readInt()
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readLong

        public long readLong()
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • readDouble

        public double readDouble()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readShort

        public short readShort()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readFloat

        public float readFloat()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • 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