Class LengthLimitedInputStream

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

    public class LengthLimitedInputStream
    extends java.io.FilterInputStream
    Implements a stream that wraps another input stream, but limits the portion read.
    • Field Summary

      • Fields inherited from class java.io.FilterInputStream

        in
    • Constructor Summary

      Constructors 
      Constructor Description
      LengthLimitedInputStream​(java.io.InputStream in, long offset, long size)
      Creates a new instance wrapping the given input stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      int read()  
      int read​(byte[] b, int off, int len)  
      long skip​(long n)  
      • Methods inherited from class java.io.FilterInputStream

        close, mark, markSupported, read, reset
      • 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
    • Constructor Detail

      • LengthLimitedInputStream

        public LengthLimitedInputStream​(java.io.InputStream in,
                                        long offset,
                                        long size)
                                 throws java.io.IOException
        Creates a new instance wrapping the given input stream.
        Parameters:
        in - the underlying input stream
        offset - the offset from the start of the stream to begin reading
        size - the size of the portion of the data to read
        Throws:
        java.io.IOException - if there is an error accessing the underlying input stream
    • Method Detail

      • available

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

        public int read()
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • skip

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