Package adams.core.io

Class BufferedFileWriter

    • Field Detail

      • m_FileWriter

        protected FileWriter m_FileWriter
        the file writer.
      • m_BufferedWriter

        protected BufferedWriter m_BufferedWriter
        the buffered writer.
    • Constructor Detail

      • BufferedFileWriter

        public BufferedFileWriter​(File file)
                           throws Exception
        Initializes the writer with the given file.
        Parameters:
        file - the file to write to
        Throws:
        Exception - if instantiation of writer fails
      • BufferedFileWriter

        public BufferedFileWriter​(String file)
                           throws Exception
        Initializes the writer with the given file.
        Parameters:
        file - the file to write to
        Throws:
        Exception - if instantiation of writer fails
    • Method Detail

      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
                   throws IOException
        Writes a portion of an array of characters.
        Specified by:
        write in class Writer
        Parameters:
        cbuf - Array of characters
        off - Offset from which to start writing characters
        len - Number of characters to write
        Throws:
        IOException - If an I/O error occurs
      • write

        public void write​(String s,
                          int off,
                          int len)
                   throws IOException
        Writes a portion of a string.
        Overrides:
        write in class Writer
        Parameters:
        s - A String
        off - Offset from which to start writing characters
        len - Number of characters to write
        Throws:
        IndexOutOfBoundsException - If off is negative, or len is negative, or off+len is negative or greater than the length of the given string
        IOException - If an I/O error occurs
      • newLine

        public void newLine()
                     throws IOException
        Writes a line separator. The line separator string is defined by the system property line.separator, and is not necessarily a single newline ('\n') character.
        Throws:
        IOException
      • flush

        public void flush()
                   throws IOException
        Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
        Specified by:
        flush in interface Flushable
        Specified by:
        flush in class Writer
        Throws:
        IOException - If an I/O error occurs
      • close

        public void close()
                   throws IOException
        Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in class Writer
        Throws:
        IOException - If an I/O error occurs