字符流 输出.write('c')运行后不会出现
public static void main(String[] args) throws Exception { Writer fw = new FileWriter(new File("data.txt")); fw.write('c'); } }
运行后data.txt一篇空白。运行速度太快使得数据还未写入硬盘中程序已经关闭。
解决方法
1:在代码后写入数据刷新代码
fw.flush();
//刷新数据 适合快速使用的代码
2:在代码后关闭输出流管道
fw.close();