import java.io.*;
public class FileAppend {
public static void main(String[] args) {
BufferedWriter bufferedWriter = null;
try {
bufferedWriter = new BufferedWriter(new FileWriter("srcFile"));
bufferedWriter.write("这是初始内容。");
bufferedWriter.close();
/**
* 开始追加内容
*/
bufferedWriter= new BufferedWriter(new FileWriter("srcFile",true));
bufferedWriter.write("请大家注意了,这是追加内容!!!!");
bufferedWriter.close();
/**
* 打印输出追加内容
*/
BufferedReader bufferedReader = new BufferedReader(new FileReader("srcFile"));
String string;
while ((string=bufferedReader.readLine()) != null){
System.out.println(string);
}
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}