Class BufferedWriter
java.lang.Object
java.io.Writer
java.io.BufferedWriter
- All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Writes text to another writer through a buffer.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBufferedWriter(Writer out) Buffersoutwith an 8192 character buffer.BufferedWriter(Writer out, int size) Buffersoutwith a buffer ofsizecharacters. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the stream, flushing it first.voidflush()Flush the stream.voidnewLine()Writes a line separator,\n.voidwrite(char[] cbuf, int off, int len) Write a portion of an array of characters.voidwrite(int c) Write a single character.voidWrite a portion of a string.
-
Constructor Details
-
BufferedWriter
Buffersoutwith an 8192 character buffer. -
BufferedWriter
Buffers
outwith a buffer ofsizecharacters.Throws
IllegalArgumentException: whensizeis not positive
-
-
Method Details
-
write
Description copied from class:WriterWrite a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored. Subclasses that intend to support efficient single-character output should override this method.- Overrides:
writein classWriter- Throws:
IOException
-
write
Description copied from class:WriterWrite a portion of an array of characters.- Specified by:
writein classWriter- Throws:
IOException
-
write
Description copied from class:WriterWrite a portion of a string.- Overrides:
writein classWriter- Throws:
IOException
-
newLine
-
flush
Description copied from class:WriterFlush 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
-
close
Description copied from class:WriterClose the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-