Package nxt.util
Class CountingInputReader
java.lang.Object
java.io.Reader
java.io.FilterReader
nxt.util.CountingInputReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
CountingInputReader extends Reader to count the number of characters read
-
Field Summary
Fields inherited from class java.io.FilterReader
in -
Constructor Summary
ConstructorsConstructorDescriptionCountingInputReader(Reader reader, long limit) Create a CountingInputReader for the supplied Reader -
Method Summary
Methods inherited from class java.io.FilterReader
close, mark, markSupported, ready, resetMethods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Constructor Details
-
CountingInputReader
Create a CountingInputReader for the supplied Reader- Parameters:
reader- Input readerlimit- Maximum number of characters to be read
-
-
Method Details
-
read
Read a single character- Overrides:
readin classFilterReader- Returns:
- Character or -1 if end of stream reached
- Throws:
IOException- I/O error occurred
-
read
Read characters into an array starting at the specified offset- Overrides:
readin classFilterReader- Parameters:
cbuf- Character arrayoff- Starting offsetlen- Number of characters to be read- Returns:
- Number of characters read or -1 if end of stream reached
- Throws:
IOException- I/O error occurred
-
skip
Skip characters in the input stream- Overrides:
skipin classFilterReader- Parameters:
n- Number of characters to skip- Returns:
- Number of characters skipped or -1 if end of stream reached
- Throws:
IOException- I/O error occurred
-
getCount
public long getCount()Return the total number of characters read- Returns:
- Character count
-