java.io
Class BufferedWriter
Java.lang.Object
Java.io.Writer
Java.io.BufferedWriter
BufferedWriter
BufferedWriter (Writer out)
-
Creates a buffered character output stream that uses the default size output buffer.
-
-
Parameters:
-
-
out
-a Writer
-
1 PackageA.ab;2 3 ImportJava.io.*;4 5 Public classFilereadwrite {6 Public Static voidMain (string[] args) {7FileWriter fw=NULL;8BufferedWriter bw=NULL;9 Try{Ten //Copy the contents of the F1 file to the F2 file OneFile f1=NewFile ("D:\\dd\\d.txt"); Afw=NewFileWriter (F1); -bw=NewBufferedWriter (FW);//character output stream with buffer - for(inti=0;i<3;i++){ theBw.write ("ABCD" +i); - bw.newline (); - Bw.flush (); - } +}Catch(Exception ex) { - ex.printstacktrace (); +}finally{ A Try { atFw.close ();//close File Write operations -}Catch(IOException e) { - e.printstacktrace (); - } - Try { - bw.close (); in}Catch(IOException e) { - e.printstacktrace (); to } + } - } the}
View Code
void |
close() Close the stream, but refresh it first. |
void |
flush() Refreshes the buffer of the stream. |
void |
newLine() Writes a line delimiter. |
Java writes text to the character output stream, buffering individual characters, providing efficient writes of individual characters, arrays, and strings.