1 package YiChangchuli;
2 import java.io.*;
3 public class TestFile3 {
4
5 public static void main(String[] args) {
6 // TODO Auto-generated method stub
7
8 try {
9 FileReader fr=new FileReader("e:\\test.txt");
10 char[] c=new char[200];
11 int i=fr.read(c);
12 String str=new String(c,0,i);
13 System.out.println("读取内容="+str);
14 //fr.close();
15
16 //写入
17 FileWriter fw=new FileWriter("e:\\test.txt",true);
18 fw.write("\n新追加的内容");
19 fw.close();
20
21
22
23 } catch (Exception e) {
24 // TODO Auto-generated catch block
25 e.printStackTrace();
26 }
27 }
28
29 }