public class CharCountingStringReader extends java.io.StringReader
StringReader that keeps tracks of the number of consumed chars
at any given time.| Modifier and Type | Field and Description |
|---|---|
protected long |
consumed
Number of consumed bytes since the beginning of the stream.
|
protected long |
counter
Byte counter which can also be changed.
|
| Constructor and Description |
|---|
CharCountingStringReader(java.lang.String str)
Creates a new
StringReader that keeps track of
consumed characters. |
| Modifier and Type | Method and Description |
|---|---|
long |
getConsumed()
Consumed length getter.
|
long |
getCounter()
Retrieve the current counter value.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(char[] cbuf,
int off,
int len) |
java.lang.String |
readLine()
Reads a line defined as characters read until encountering a
LF or EOF. |
void |
reset() |
void |
setCounter(long bytes)
Change the counter value.
|
long |
skip(long n) |
protected long consumed
protected long counter
public CharCountingStringReader(java.lang.String str)
StringReader that keeps track of
consumed characters.str - Arbitrary string.public boolean markSupported()
markSupported in class java.io.StringReaderpublic void mark(int readlimit)
mark in class java.io.StringReaderpublic void reset() throws java.io.IOException
reset in class java.io.StringReaderjava.io.IOExceptionpublic long getConsumed()
public void setCounter(long bytes)
bytes - new counter valuepublic long getCounter()
public int read() throws java.io.IOException
read in class java.io.StringReaderjava.io.IOExceptionpublic int read(char[] cbuf, int off, int len) throws java.io.IOException
read in class java.io.StringReaderjava.io.IOExceptionpublic long skip(long n) throws java.io.IOException
skip in class java.io.StringReaderjava.io.IOExceptionpublic java.lang.String readLine() throws java.io.IOException
LF or EOF.StringReaderjava.io.IOException - if an I/O error occurs while reading lineCopyright © 2011–2023. All rights reserved.