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());
}
}
}
}