Class ResettableBoundedInputStream

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

    public class ResettableBoundedInputStream
    extends java.io.InputStream
    Bounded input stream where the limit can be set dynamically.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()  
      boolean markSupported()  
      int read()  
      int read​(byte[] buffer, int offset, int length)  
      void resetLimit​(long limit)
      Make this input stream return EOF after the specified number of bytes.
      long skip​(long distance)  
      • Methods inherited from class java.io.InputStream

        mark, nullInputStream, read, 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

      • ResettableBoundedInputStream

        public ResettableBoundedInputStream​(java.io.InputStream delegate)
        Parameters:
        delegate - Underlying input stream.
    • Method Detail

      • resetLimit

        public void resetLimit​(long limit)
        Make this input stream return EOF after the specified number of bytes.
        Parameters:
        limit - Maximum number of bytes that can be read.
      • 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[] buffer,
                        int offset,
                        int length)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • skip

        public long skip​(long distance)
                  throws java.io.IOException
        Overrides:
        skip 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
      • 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
      • markSupported

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