public final class CountingReader extends Reader
Reader that counts the number of characters that have
been read from its underlying Reader. Characters read multiple times
are counted as many times as they have been read. Skipped characters are not
counted.| Constructor and Description |
|---|
CountingReader(Reader reader)
Creates a new
CountingReader. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
long |
getCount()
Returns the number of characters that have been read from the
underlying stream so far.
|
void |
mark(int readLimit) |
boolean |
markSupported() |
int |
read() |
int |
read(char[] buf) |
int |
read(char[] buf,
int off,
int len) |
boolean |
ready() |
void |
reset() |
long |
resetCount()
Sets the counter to 0 and returns its value before resetting it.
|
long |
skip(long n) |
public CountingReader(Reader reader)
CountingReader.reader - the underlying reader.NullPointerException - if reader is null.public long getCount()
public long resetCount()
public boolean ready()
throws IOException
ready in class ReaderIOExceptionpublic int read()
throws IOException
read in class ReaderIOExceptionpublic int read(char[] buf)
throws IOException
read in class ReaderIOExceptionpublic int read(char[] buf,
int off,
int len)
throws IOException
read in class ReaderIOExceptionpublic boolean markSupported()
markSupported in class Readerpublic void mark(int readLimit)
throws IOException
mark in class ReaderIOExceptionpublic void reset()
throws IOException
reset in class ReaderIOExceptionpublic long skip(long n)
throws IOException
skip in class ReaderIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class ReaderIOExceptionCopyright © 2012–2015. All rights reserved.