- FileWriter字符输出
@Test public void test3(){ File file = new File("hello1.txt"); FileWriter fw = null; try { //自动创建文件。默认false,覆盖写;true追加写 fw = new FileWriter(file, true); fw.write("天南地北"); } catch (IOException e) { e.printStackTrace(); }finally { if (fw != null){ try { fw.close(); } catch (IOException e) { e.printStackTrace(); } } } }