Java Read File Learning

Source: Internet
Author: User

1.FileWriter writer = new FileWriter (filename,true);
True indicates that the base of the original text is appended.
2.
BufferedWriter
The efficiency of writing becomes a problem when the content of the file is written. You can use BufferedWriter to cushion it.
Both the BufferedWriter and FileWriter classes are used to output character streams, which contain almost identical methods, but BufferedWriter provides a newline () method for line wrapping. This line break is cross-platform.
public class Bufferedwritertester {


public static void Main (string[] args) throws ioexception{
TODO auto-generated Method Stub
String filename = "NewHello.txt";
BufferedWriter out = new BufferedWriter (new FileWriter (filename));
Out.write ("Hello");
Out.newline ();
Out.write ("I can start from another line");
Out.close ();
}

}

3. Reading characters from a text file
FileReader class:
-read characters from a text file
-Inherits from the subclass of the reader abstract class InputStreamReader
BufferedReader
-Buffer class for reading text files
-With the ReadLine () method, you can identify the line character and read the contents of the input stream in one line.
-Inherit from reader.

Java Read File Learning

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.