Class SubImageInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.DataInput, java.lang.AutoCloseable, javax.imageio.stream.ImageInputStream

    public final class SubImageInputStream
    extends javax.imageio.stream.ImageInputStreamImpl
    A wrapper for ImageInputStream to limit the number of bytes that can be read.
    Version:
    $Id: SubImageInputStream.java,v 1.0 Nov 8, 2009 2:50:58 PM haraldk Exp$
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long length  
      private long startPos  
      private javax.imageio.stream.ImageInputStream stream  
      • Fields inherited from class javax.imageio.stream.ImageInputStreamImpl

        bitOffset, byteOrder, flushedPos, streamPos
    • Constructor Summary

      Constructors 
      Constructor Description
      SubImageInputStream​(javax.imageio.stream.ImageInputStream stream, long length)
      Creates a ImageInputStream, reading up to a maximum number of bytes from the underlying stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void finalize()  
      long length()  
      int read()  
      int read​(byte[] bytes, int off, int len)  
      void seek​(long position)  
      • Methods inherited from class javax.imageio.stream.ImageInputStreamImpl

        checkClosed, close, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, mark, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, setBitOffset, setByteOrder, skipBytes, skipBytes
      • Methods inherited from class java.lang.Object

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

      • stream

        private final javax.imageio.stream.ImageInputStream stream
      • startPos

        private final long startPos
      • length

        private final long length
    • Constructor Detail

      • SubImageInputStream

        public SubImageInputStream​(javax.imageio.stream.ImageInputStream stream,
                                   long length)
                            throws java.io.IOException
        Creates a ImageInputStream, reading up to a maximum number of bytes from the underlying stream.
        Parameters:
        stream - the underlying stream
        length - the maximum length to read from the stream. Note that stream may contain less than this maximum number of bytes.
        Throws:
        java.io.IOException - if stream's position can't be determined.
        java.lang.IllegalArgumentException - if stream == null or length < 0
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in interface javax.imageio.stream.ImageInputStream
        Specified by:
        read in class javax.imageio.stream.ImageInputStreamImpl
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] bytes,
                        int off,
                        int len)
                 throws java.io.IOException
        Specified by:
        read in interface javax.imageio.stream.ImageInputStream
        Specified by:
        read in class javax.imageio.stream.ImageInputStreamImpl
        Throws:
        java.io.IOException
      • length

        public long length()
        Specified by:
        length in interface javax.imageio.stream.ImageInputStream
        Overrides:
        length in class javax.imageio.stream.ImageInputStreamImpl
      • seek

        public void seek​(long position)
                  throws java.io.IOException
        Specified by:
        seek in interface javax.imageio.stream.ImageInputStream
        Overrides:
        seek in class javax.imageio.stream.ImageInputStreamImpl
        Throws:
        java.io.IOException
      • finalize

        protected void finalize()
        Overrides:
        finalize in class javax.imageio.stream.ImageInputStreamImpl