/**
* @author Jack.
* @Date: 2011-1-7.
* @Time: 05:50:40.
* @FileName: Testwriter.java.
* @Version 1.0
*/
public class Testwriter
{
Function: Reads the contents of the E:/test.txt file (read one line) and writes its contents to the E:/jack.txt
Knowledge Point: Java reads the file, writes the file---< by the character Stream way >
public static void Main (string[] args)
{
Try
{
Create a FileReader object to read a character stream
FileReader FR = new FileReader ("E:/test.txt");
Buffer the input of the specified file
BufferedReader br = new BufferedReader (FR);
Creates a FileWriter object that is used to write character streams
FileWriter FW = new FileWriter ("E:/jack.txt");
Will buffer the output to the file
BufferedWriter bw = new BufferedWriter (FW);
Defines a variable of type string that is used to read one row at a time
String Myreadline;
while (Br.ready ())
{
Read one line
Myreadline = Br.readline ();
Write to File
Bw.write (Myreadline);
Bw.newline ();
Output on the screen
System.out.println (Myreadline);
}
Refresh the buffer for this stream
Bw.flush ();
Bw.close ();
Br.close ();
Fw.close ();
Br.close ();
Fr.close ();
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