import java.io.FileWriter;
import java.io.IOException;
public class FileWirterDemo1 {
/**
* @param args
*/
public static void main(String[] args) {
FileWriter fw =null;
try {
fw = new FileWriter("D:\\file.txt",true); // true表示续写
fw.write("ddd\r\nxxx"); //空指针异常 换行 windows下\r\n linux下\n } catch (IOException e) {
e.printStackTrace();
}finally{
try {
if(fw!=null){
fw.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}