java怎么才能把一个变量中的字符串变量输出到一个文本文件中?
rt
------解决方案--------------------try {
String s = "test ";
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(new FileOutputStream( "C:\\test.txt ")));
br.write(s);
} catch (
IOException e) {
e.printStackTrace();
}
------解决方案--------------------brooksychen(初晨之阳) 老兄你是不是天天都泡在上面啊?
我一看帖子 就有你的答案
我会的都没法回了
try {
String s = "test ";
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(new FileOutputStream( "C:\\test.txt ")));
br.write(s);
} catch (IOException e) {
e.printStackTrace();
}
这代码已经标准的不得了了
我当时学习的 时候用的就是它
------解决方案--------------------炒冷饭,来个更简洁的。
try {
BufferedWriter out = new BufferedWriter(new FileWriter( "C:\myfile.txt "));
out.write( "aString ");
out.close();
} catch (IOException e) {
}