
import java.io.*;
/**
* 字符流写入文件
*
*/
public class FileWriteTest {
public static void main(String[] args) {
FileWriteTest t = new FileWriteTest();
t.WriteMyFile();
}
void WriteMyFile() {
try {
FileWriter fw = new FileWriter("mydata.txt");
PrintWriter out = new PrintWriter(fw);
out.print("写入文件");
out.close();
fw.close();
} catch (IOException e) {
System.out.println("写入错误");
e.printStackTrace();
}
}
}



初级程序员
by: 微微 发表于:2016-08-21 20:49:27 顶(0) | 踩(0) 回复
。。。。
回复评论