Io Stream (FileWriter)

Source: Internet
Author: User

/*

* Character Stream features:

* Since IO stream is used to manipulate data. The most common form of data is: file

* Then, you need to create a file on your hard disk and write some text data

*/

Import java.io.*;

public class FileWriter

{

public static void Main (string[] args) throws IOException

{

/*

* Create an FileWriter object that must be explicitly manipulated when initialized.

* Moreover, the file will be created to the specified directory, if the directory already has the same name file, will be overwritten

* In fact, the step is to clear the destination of the data to be stored

*/

FileWriter fw= New FileWriter ("Demo.txt");

Invokes the writer method, writes a string to the stream

Fw.write ("ABCDE");

/*

* Refreshes buffered data in stream objects and brushes the data to the destination

*/

Fw.flush ();

/*

* The stream resource is closed, but the data in the internal buffer is flushed once before it is closed

* Swipe the data to the destination

* and flush difference: After flush refreshes, the stream can continue to be used, and when close is refreshed, the stream is closed

*/

Fw.clone ();

}

}

Io Stream (FileWriter)

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.