Package nxt.util

Class CountingOutputWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class CountingOutputWriter
    extends java.io.FilterWriter
    CountingOutputWriter extends Writer to count the number of characters written
    • Field Summary

      • Fields inherited from class java.io.FilterWriter

        out
      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      CountingOutputWriter​(java.io.Writer writer)
      Create the CountingOutputWriter for the specified writer
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getCount()
      Return the number of characters written
      void write​(char[] cbuf)
      Write an array of characters
      void write​(char[] cbuf, int off, int len)
      Write an array of characters starting at the specified offset
      void write​(int c)
      Write a single character
      void write​(java.lang.String s)
      Write a string
      void write​(java.lang.String s, int off, int len)
      Write a substring
      • Methods inherited from class java.io.FilterWriter

        close, flush
      • Methods inherited from class java.io.Writer

        append, append, append, nullWriter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CountingOutputWriter

        public CountingOutputWriter​(java.io.Writer writer)
        Create the CountingOutputWriter for the specified writer
        Parameters:
        writer - Output writer
    • Method Detail

      • write

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

        public void write​(char[] cbuf)
                   throws java.io.IOException
        Write an array of characters
        Overrides:
        write in class java.io.Writer
        Parameters:
        cbuf - Characters to be written
        Throws:
        java.io.IOException - I/O error occurred
      • write

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

        public void write​(java.lang.String s)
                   throws java.io.IOException
        Write a string
        Overrides:
        write in class java.io.Writer
        Parameters:
        s - String to be written
        Throws:
        java.io.IOException - I/O error occurred
      • write

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

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