Class FastBufferedWriter

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

    final class FastBufferedWriter
    extends java.io.FilterWriter
    implements Writable
    High-performance buffered writer (without synchronization).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean autoFlushBuffer  
      private boolean autoFlushWriter  
      private char[] buf  
      private int pos  
      • Fields inherited from class java.io.FilterWriter

        out
      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      FastBufferedWriter​(java.io.Writer writer, int bufferSize, boolean autoFlushBuffer, boolean autoFlushWriter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void endRecord()
      Called to indicate that the current record is complete.
      void flush()  
      private void flushBuffer()  
      void write​(char[] cbuf, int off, int len)
      Writes a portion of an array of characters.
      void write​(int c)
      Writes a single character.
      void write​(java.lang.String str, int off, int len)
      Writes a portion of a string.
      • Methods inherited from class java.io.Writer

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

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

      • buf

        private final char[] buf
      • autoFlushBuffer

        private final boolean autoFlushBuffer
      • autoFlushWriter

        private final boolean autoFlushWriter
      • pos

        private int pos
    • Constructor Detail

      • FastBufferedWriter

        FastBufferedWriter​(java.io.Writer writer,
                           int bufferSize,
                           boolean autoFlushBuffer,
                           boolean autoFlushWriter)
    • Method Detail

      • write

        public void write​(int c)
                   throws java.io.IOException
        Description copied from interface: Writable
        Writes a single character.
        Specified by:
        write in interface Writable
        Overrides:
        write in class java.io.FilterWriter
        Parameters:
        c - the character to write
        Throws:
        java.io.IOException
        See Also:
        Writer.write(int)
      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
                   throws java.io.IOException
        Description copied from interface: Writable
        Writes a portion of an array of characters.
        Specified by:
        write in interface Writable
        Overrides:
        write in class java.io.FilterWriter
        Parameters:
        cbuf - the array of characters to write
        off - the offset from which to start writing characters
        len - the number of characters to write
        Throws:
        java.io.IOException
        See Also:
        Writer.write(char[], int, int)
      • write

        public void write​(java.lang.String str,
                          int off,
                          int len)
                   throws java.io.IOException
        Description copied from interface: Writable
        Writes a portion of a string.
        Specified by:
        write in interface Writable
        Overrides:
        write in class java.io.FilterWriter
        Parameters:
        str - the string to write
        off - the offset from which to start writing characters
        len - the number of characters to write
        Throws:
        java.io.IOException
        See Also:
        Writer.write(String, int, int)
      • endRecord

        public void endRecord()
                       throws java.io.IOException
        Description copied from interface: Writable
        Called to indicate that the current record is complete.
        Specified by:
        endRecord in interface Writable
        Throws:
        java.io.IOException - if an I/O error occurs
      • flushBuffer

        private void flushBuffer()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterWriter
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterWriter
        Throws:
        java.io.IOException