Class BoundedReader

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

    public class BoundedReader
    extends java.io.Reader
    A reader that imposes a limit to the number of bytes that can be read from an underlying reader, simulating eof when this limit is reached. This stream can typically be used to constrain a client with regard to a readAheadLimit of an underlying stream, to avoid overrunning this limit and hence lose the opportunity do to reset.
    • Field Summary

      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      BoundedReader​(java.io.Reader target, int readAheadLimit)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void mark​(int theReadAheadLimit)  
      int read()  
      int read​(char[] cbuf, int off, int len)  
      void reset()  
      • Methods inherited from class java.io.Reader

        markSupported, nullReader, read, read, ready, skip, transferTo
      • Methods inherited from class java.lang.Object

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

      • BoundedReader

        public BoundedReader​(java.io.Reader target,
                             int readAheadLimit)
                      throws java.io.IOException
        Parameters:
        target - Reader
        readAheadLimit - read ahead limit.
        Throws:
        java.io.IOException - in case of a failure.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Reader
        Throws:
        java.io.IOException
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides:
        reset in class java.io.Reader
        Throws:
        java.io.IOException
      • mark

        public void mark​(int theReadAheadLimit)
                  throws java.io.IOException
        Overrides:
        mark in class java.io.Reader
        Throws:
        java.io.IOException
      • read

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

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Specified by:
        read in class java.io.Reader
        Throws:
        java.io.IOException