Java Io-bufferedreader & BufferedWriter

Source: Internet
Author: User

The Java.io package offers a wide range of IO read and write functions, packaged in different classes. The BufferedReader and bufferedwriter can be used to read and write files conveniently.

Examples of use are as follows:

Import Staticjava.lang.System.out;ImportJava.io.BufferedReader;ImportJava.io.BufferedWriter;ImportJava.io.FileReader;ImportJava.io.FileWriter; Public classFilereaderexample { Public Final StaticString path_in = "Src/resources/data_input.txt";  Public Final StaticString path_out = "Src/resources/data_output.txt"; /*** Example of BufferedReader and BufferedWriter * *@throwsException*/     Public voidBufferedreader_writer ()throwsException {FileReader fr=NewFileReader (path_in); BufferedReader BR=NewBufferedReader (FR); FileWriter FW=NewFileWriter (path_out); BufferedWriter BW=NewBufferedWriter (FW);        String Line;  while(line = Br.readline ())! =NULL) {out.println (line); Bw.write ( Line+ "\ n"); } String endstr= "-End of BufferedReader";        Out.print (ENDSTR); Bw.write (Endstr+ "\ n");        Br.close ();    Bw.close (); }}

Resources:

Java IO BufferedReader, Tutorialspoint

Java Files and IO, Tutorialspint

Java Io-bufferedreader & BufferedWriter

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.