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

- - ### Field Summary

    - ### Fields inherited from class java.io.FilterReader

      `in`

    - ### Fields inherited from class java.io.Reader

      `lock`

  - ### Constructor Summary

    Constructors
    Constructor and 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 and Description
    --- | ---
    `long` | `getCount()` Return the total number of characters read
    `int` | `read()` Read a single character
    `int` | `read(char[] cbuf, int off, int len)` Read characters into an array starting at the specified offset
    `long` | `skip(long n)` Skip characters in the input stream

    - ### Methods inherited from class java.io.FilterReader

      `close, mark, markSupported, ready, reset`

    - ### Methods inherited from class java.io.Reader

      `read, read`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CountingInputReader

          public CountingInputReader(java.io.Reader reader,
                                     long limit)

      Create a CountingInputReader for the supplied Reader
      Parameters:
        `reader` - Input reader
        `limit` - Maximum number of characters to be read

  - ### Method Detail

    - #### read

          public int read()
                   throws java.io.IOException

      Read a single character
      Overrides:
        `read` in class `java.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,
                          int off,
                          int len)
                   throws java.io.IOException

      Read characters into an array starting at the specified offset
      Overrides:
        `read` in class `java.io.FilterReader`
      Parameters:
        `cbuf` - Character array
        `off` - Starting offset
        `len` - 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 class `java.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