Package adams.core.io
Class BufferedFileWriter
- java.lang.Object
-
- java.io.Writer
-
- adams.core.io.BufferedFileWriter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class BufferedFileWriter extends Writer
Combines aBufferedWriterand aFileWriter.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected BufferedWriterm_BufferedWriterthe buffered writer.protected FileWriterm_FileWriterthe file writer.
-
Constructor Summary
Constructors Constructor Description BufferedFileWriter(File file)Initializes the writer with the given file.BufferedFileWriter(String file)Initializes the writer with the given file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the stream, flushing it first.voidflush()Flushes the stream.voidnewLine()Writes a line separator.voidwrite(char[] cbuf, int off, int len)Writes a portion of an array of characters.voidwrite(String s, int off, int len)Writes a portion of a string.
-
-
-
Field Detail
-
m_FileWriter
protected FileWriter m_FileWriter
the file writer.
-
m_BufferedWriter
protected BufferedWriter m_BufferedWriter
the buffered writer.
-
-
Method Detail
-
write
public void write(char[] cbuf, int off, int len) throws IOExceptionWrites a portion of an array of characters.- Specified by:
writein classWriter- Parameters:
cbuf- Array of charactersoff- Offset from which to start writing characterslen- 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:
writein classWriter- Parameters:
s- A Stringoff- Offset from which to start writing characterslen- 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 stringIOException- If an I/O error occurs
-
newLine
public void newLine() throws IOExceptionWrites 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 IOExceptionFlushes 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:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException- If an I/O error occurs
-
close
public void close() throws IOExceptionCloses 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException- If an I/O error occurs
-
-