Class IIOInputStreamAdapter

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

    class IIOInputStreamAdapter
    extends java.io.InputStream
    IIOInputStreamAdapter

    Note: You should always wrap this stream in a BufferedInputStream. If not, performance may degrade significantly.

    Version:
    $Id: IIOInputStreamAdapter.java,v 1.0 Sep 26, 2007 11:35:59 AM haraldk Exp$
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean hasLength  
      private javax.imageio.stream.ImageInputStream input  
      private long left  
      private long markPosition  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        IIOInputStreamAdapter​(javax.imageio.stream.ImageInputStream pInput)
      Creates an InputStream that reads from the given ImageInputStream.
        IIOInputStreamAdapter​(javax.imageio.stream.ImageInputStream pInput, long pLength)
      Creates an InputStream that reads from the given ImageInputStream.
      private IIOInputStreamAdapter​(javax.imageio.stream.ImageInputStream pInput, long pLength, boolean pHasLength)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()
      Marks this stream as closed.
      private long findMaxLen​(long pLength)
      Finds the maximum number of bytes we can read or skip, from this stream.
      void mark​(int pReadLimit)  
      boolean markSupported()  
      int read()  
      int read​(byte[] pBytes)  
      int read​(byte[] pBytes, int pOffset, int pLength)  
      void reset()  
      long skip​(long pLength)  
      • Methods inherited from class java.io.InputStream

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

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

      • input

        private javax.imageio.stream.ImageInputStream input
      • hasLength

        private final boolean hasLength
      • left

        private long left
      • markPosition

        private long markPosition
    • Constructor Detail

      • IIOInputStreamAdapter

        public IIOInputStreamAdapter​(javax.imageio.stream.ImageInputStream pInput)
        Creates an InputStream that reads from the given ImageInputStream. The input stream will read from the current stream position, until the end of the underlying stream.
        Parameters:
        pInput - the ImageInputStream to read from.
      • IIOInputStreamAdapter

        public IIOInputStreamAdapter​(javax.imageio.stream.ImageInputStream pInput,
                                     long pLength)
        Creates an InputStream that reads from the given ImageInputStream. The input stream will read from the current stream position, until at most pLength bytes has been read.
        Parameters:
        pInput - the ImageInputStream to read from.
        pLength - the length of the stream
      • IIOInputStreamAdapter

        private IIOInputStreamAdapter​(javax.imageio.stream.ImageInputStream pInput,
                                      long pLength,
                                      boolean pHasLength)
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Marks this stream as closed. This implementation does not close the underlying stream.
        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
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException
      • markSupported

        public boolean markSupported()
        Overrides:
        markSupported in class java.io.InputStream
      • mark

        public void mark​(int pReadLimit)
        Overrides:
        mark in class java.io.InputStream
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides:
        reset in class java.io.InputStream
        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 final int read​(byte[] pBytes)
                       throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] pBytes,
                        int pOffset,
                        int pLength)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • findMaxLen

        private long findMaxLen​(long pLength)
        Finds the maximum number of bytes we can read or skip, from this stream. The number will be in the range [0 ... bytes left].
        Parameters:
        pLength - the requested length
        Returns:
        the maximum number of bytes to read
      • skip

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