Package nxt.util

Class CountingOutputWriter

All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class CountingOutputWriter extends FilterWriter
CountingOutputWriter extends Writer to count the number of characters written
  • Constructor Details

    • CountingOutputWriter

      public CountingOutputWriter(Writer writer)
      Create the CountingOutputWriter for the specified writer
      Parameters:
      writer - Output writer
  • Method Details

    • write

      public void write(int c) throws IOException
      Write a single character
      Overrides:
      write in class FilterWriter
      Parameters:
      c - Character to be written
      Throws:
      IOException - I/O error occurred
    • write

      public void write(char[] cbuf, int off, int len) throws IOException
      Write an array of characters starting at the specified offset
      Overrides:
      write in class FilterWriter
      Parameters:
      cbuf - Characters to be written
      off - Starting offset
      len - Number of characters to write
      Throws:
      IOException - I/O error occurred
    • write

      public void write(String s, int off, int len) throws IOException
      Write a substring
      Overrides:
      write in class FilterWriter
      Parameters:
      s - String to be written
      off - Starting offset
      len - Number of characters to write
      Throws:
      IOException - I/O error occurred
    • getCount

      public long getCount()
      Return the number of characters written
      Returns:
      Character count