? BoundedReader

java.lang.Object
java.io.Reader
org.apache.commons.io.input.BoundedReader
????????:
Closeable, AutoCloseable, Readable

public class BoundedReader extends Reader
A reader that imposes a limit to the number of characters that can be read from an underlying reader, returning EOF when this limit is reached, regardless of state of underlying reader.

One use case is to avoid overrunning the readAheadLimit supplied to Reader.mark(int), since reading too many characters removes the ability to do a successful reset.

???????:
2.5
  • ???????

    • BoundedReader

      public BoundedReader(Reader target, int maxCharsFromTargetReader)
      Constructs a bounded reader
      ??:
      target - The target stream that will be used
      maxCharsFromTargetReader - The maximum number of characters that can be read from target
  • ??????

    • close

      public void close() throws IOException
      Closes the target
      ???:
      close ???? AutoCloseable
      ???:
      close ???? Closeable
      ???:
      close ??? Reader
      ??:
      IOException - If an I/O error occurs while calling the underlying reader's close method
    • reset

      public void reset() throws IOException
      Resets the target to the latest mark,
      ??:
      reset ??? Reader
      ??:
      IOException - If an I/O error occurs while calling the underlying reader's reset method
      ????:
    • mark

      public void mark(int readAheadLimit) throws IOException
      marks the target stream
      ??:
      mark ??? Reader
      ??:
      readAheadLimit - The number of characters that can be read while still retaining the ability to do #reset(). Note that this parameter is not validated with respect to maxCharsFromTargetReader. There is no way to pass past maxCharsFromTargetReader, even if this value is greater.
      ??:
      IOException - If an I/O error occurs while calling the underlying reader's mark method
      ????:
    • read

      public int read() throws IOException
      Reads a single character
      ??:
      read ??? Reader
      ??:
      -1 on EOF or the character read
      ??:
      IOException - If an I/O error occurs while calling the underlying reader's read method
      ????:
    • read

      public int read(char[] cbuf, int off, int len) throws IOException
      Reads into an array
      ???:
      read ??? Reader
      ??:
      cbuf - The buffer to fill
      off - The offset
      len - The number of chars to read
      ??:
      the number of chars read
      ??:
      IOException - If an I/O error occurs while calling the underlying reader's read method
      ????: