Number 据 I / O

1. Application of the file output stream.
  String is defined as follows:
  String str = "12345abcdef @ #% & * Software Engineering";
  programming the string to the file "data.txt".

package homework;

import java.io. *;

public class IO {

public static void main(String[] args) throws IOException{

STE = String "12345abcdef @ #% & * Software Engineering";

File f1=new File("C:\\Users\\WIN10\\Desktop\\data.txt");

f1.createNewFile();

System.out.println("名称"+f1.getName());

FileWriter fy=new FileWriter(f1);

BufferedWriter fw=new BufferedWriter(fy);

fw.write(ste);

fw.close();

fy.close();

}

}

2. The application file input stream.
   Modify the program title in the first, reading a file "data.txt", the read data output in the console.

package homework;
import java.io.*;
public class readFile {
public static void main(String[] args) throws IOException {
String ss;
File f1=new File("C:\Users\WIN10\Desktop\data.txt");
FileReader fw=new FileReader(f1);
BufferedReader fy=new BufferedReader(fw);
while((ss=fy.readLine())!=null){
System.out.println(ss);
}
fy.close();
fw.close();
}

}

3. The training of talk about experience

Variable data objects, etc. are temporarily after the end of the program will be lost, and I / O technology can save data to a text file, to master the process technology can improve their ability to handle the data. But to skilled also requires a lot of practice, so we need more efforts themselves to the

Guess you like

Origin www.cnblogs.com/ccqblog1127/p/11140872.html