写文件的问题. 打开文件是可以用添加模式FileWriter writer =new FileWriter("file.txt",true) ~~~~~最后的 true 表示写入的内容将被添加在原有文件之后 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 try:StringBuffer txtConcent = new StringBuffer() ;String sSrcName="c:\\test.txt";txtConcent.append("abc\n") ;try { PrintWriter pw = new PrintWriter(new FileWriter(sSrcName, true), true); pw.println(txtConcent.toString()); } catch (Exception e) { System.out.println("error"); }} public void writeToFile(String filename, String msg, boolean append){ PrintWriter out; //String filename = filename; try{ out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)), append); out.println(msg); }catch(IOException ioe){ System.out.println(ioe); } } writeToFile("Hello World!\n", "c:\\out.txt", true); Java swing中数组JPanel[]能否循环绑定监听事件 求java经典面试题及答案讲解 DES加密 windws上加密,linux不能解密 多线程问题(请指教) 一个很简单的多线程问题 double类型比较的问题 ~~~~谁知道jbuilderx 怎么让tab键=format???~~~~谁知道jbuilderx 怎么让tab键=format???~~~~ Thinking in Java 到底好不好? Java的输入问题 请问如何在TOMCAT4下部署一个WAR文件???? 谁可以告诉我JBuilder4的注册码? 请问哪位知道Cloudscape下载地址?
String sSrcName="c:\\test.txt";
txtConcent.append("abc\n") ;
try
{
PrintWriter pw = new PrintWriter(new FileWriter(sSrcName, true), true);
pw.println(txtConcent.toString());
}
catch (Exception e)
{
System.out.println("error");
}
}
PrintWriter out;
//String filename = filename;
try{
out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)), append);
out.println(msg);
}catch(IOException ioe){
System.out.println(ioe);
}
} writeToFile("Hello World!\n", "c:\\out.txt", true);