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.FilterReader
CountingInputReader 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 long
getCount()
Return the total number of characters readint
read()
Read a single characterint
read(char[] cbuf)
Read characters into an arrayint
read(char[] cbuf, int off, int len)
Read characters into an arry starting at the specified offsetlong
skip(long n)
Skip characters in the input stream
-
-
-
Method Detail
-
read
public int read() throws java.io.IOException
Read a single character- Overrides:
read
in 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.IOException
Read characters into an array- Overrides:
read
in 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.IOException
Read characters into an arry starting at the specified offset- Overrides:
read
in 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.IOException
Skip characters in the input stream- Overrides:
skip
in 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
-
-