Java writes text to the character output stream, buffering individual characters, providing efficient writes of individual characters, arrays, and strings.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.