public class BoundedReader
extends java.io.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.
| Constructor and Description |
|---|
BoundedReader(java.io.Reader target,
int maxCharsFromTargetReader)
Constructs a bounded reader
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the target
|
void |
mark(int readAheadLimit)
marks the target stream
|
int |
read()
Reads a single character
|
int |
read(char[] cbuf,
int off,
int len)
Reads into an array
|
void |
reset()
Resets the target to the latest mark,
|
public BoundedReader(java.io.Reader target,
int maxCharsFromTargetReader)
target - The target stream that will be usedmaxCharsFromTargetReader - The maximum number of characters that can be read from targetpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Readerjava.io.IOException - If an I/O error occurs while calling the underlying reader's close methodpublic void mark(int readAheadLimit)
throws java.io.IOException
mark in class java.io.ReaderreadAheadLimit - 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.java.io.IOException - If an I/O error occurs while calling the underlying reader's mark methodReader.mark(int)public int read()
throws java.io.IOException
read in class java.io.Readerjava.io.IOException - If an I/O error occurs while calling the underlying reader's read methodReader.read()public int read(char[] cbuf,
int off,
int len)
throws java.io.IOException
read in class java.io.Readercbuf - The buffer to filloff - The offsetlen - The number of chars to readjava.io.IOException - If an I/O error occurs while calling the underlying reader's read methodReader.read(char[], int, int)public void reset()
throws java.io.IOException
reset in class java.io.Readerjava.io.IOException - If an I/O error occurs while calling the underlying reader's reset methodReader.reset()Copyright © 2010 - 2023 Adobe. All Rights Reserved