Java BufferedWriter ClassJava BufferedWriter class is used to provide buffering for Writer instances. It makes the performance fast. It inherits Writer class. The buffering characters are used for providing the efficient writing of single arrays, characters, and strings.
Class declarationLet's see the declaration for Java.io.BufferedWriter class:
Class constructorsConstructor | Description |
---|
BufferedWriter(Writer wrt) | It is used to create a buffered character output stream that uses the default size for an output buffer. | BufferedWriter(Writer wrt, int size) | It is used to create a buffered character output stream that uses the specified size for an output buffer. |
Class methodsMethod | Description |
---|
void newLine() | It is used to add a new line by writing a line separator. | void write(int c) | It is used to write a single character. | void write(char[] cbuf, int off, int len) | It is used to write a portion of an array of characters. | void write(String s, int off, int len) | It is used to write a portion of a string. | void flush() | It is used to flushes the input stream. | void close() | It is used to closes the input stream |
Example of Java BufferedWriterLet's see the simple example of writing the data to a text file testout.txt using Java BufferedWriter. Output: testout.txt:
|