/*
* 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)