io流文件输入输出’
package syj;
2 import java.io.*;
3 public class syj4 {
4 public static void main(String[] args) {
5 // TODO 自动生成的方法存根
6 File file = new File("data.txt");
7 String syj = "12345abcdef@#%&*软件工程 ";
8 try {
9 FileWriter t = new FileWriter (file);
10 BufferedWriter out = new BufferedWriter (t);
11 out.write(syj);
12 out.close();
13 t.close();
14 } catch (Exception e) {
15 e.printStackTrace();
16 }
17 try {
18 FileReader fr = new FileReader(file);
19 BufferedReader in = new BufferedReader(fr);
20 String ss = in.readLine();
21 System.out.println("文件中的信息是:"+ ss);
22 in.close();
23 fr.close();
24 }catch (Exception e) {
25 e.printStackTrace();
26 }
27 }
28 }