import java.io.FileWriter;
import java.io.IOException;
public class IODemo3 {
public static void main(String[] args) {
//传递一个参数表示,不覆盖已有文件,并在已有文件末尾处
//进行数据的续写
FileWriter fw=null;
try {
fw = new FileWriter("G:\\demo.txt",true);
fw.write("你好\r\n哈喽");//windows里txt文件换行符\r\n
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.toString());
}finally{
try {
if(fw!=null){
fw.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.toString());
}
}
}
}