Package nxt.util
Class CountingInputReader
- java.lang.Object
-
- java.io.Reader
-
- java.io.FilterReader
-
- nxt.util.CountingInputReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
public class CountingInputReader extends java.io.FilterReaderCountingInputReader extends Reader to count the number of characters read
-
-
Constructor Summary
Constructors Constructor Description CountingInputReader(java.io.Reader reader, long limit)Create a CountingInputReader for the supplied Reader
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()Return the total number of characters readintread()Read a single characterintread(char[] cbuf)Read characters into an arrayintread(char[] cbuf, int off, int len)Read characters into an arry starting at the specified offsetlongskip(long n)Skip characters in the input stream
-
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionRead a single character- Overrides:
readin classjava.io.FilterReader- Returns:
- Character or -1 if end of stream reached
- Throws:
java.io.IOException- I/O error occurred
-
read
public int read(char[] cbuf) throws java.io.IOExceptionRead characters into an array- Overrides:
readin classjava.io.Reader- Parameters:
cbuf- Character array- Returns:
- Number of characters read or -1 if end of stream reached
- Throws:
java.io.IOException- I/O error occurred
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOExceptionRead characters into an arry starting at the specified offset- Overrides:
readin classjava.io.FilterReader- 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:
java.io.IOException- I/O error occurred
-
skip
public long skip(long n) throws java.io.IOExceptionSkip characters in the input stream- Overrides:
skipin classjava.io.FilterReader- Parameters:
n- Number of characters to skip- Returns:
- Number of characters skipped or -1 if end of stream reached
- Throws:
java.io.IOException- I/O error occurred
-
getCount
public long getCount()
Return the total number of characters read- Returns:
- Character count
-
-