如题所述
FileWriter fw = null; try { fw = new FileWriter( "D:\\x.txt",true); // 第二个参数 true 表示写入方式是追加方式 fw.write(new Date() + " : 哈哈" + "\r\n"); } catch (Exception e) { System.out.println("书写日志发生错误:" + e.toString()); } finally { try{ fw.close(); }catch (IOException e){ // TODO 自动生成 catch 块 e.printStackTrace(); } } }}
温馨提示:答案为网友推荐,仅供参考
第1个回答 推荐于2016-10-28
FileWriter fw = null; try { fw = new FileWriter( "D:\\x.txt",true); // 第二个参数 true 表示写入方式是追加方式 fw.write(new Date() + " : 哈哈" + "\r\n"); } catch (Exception e) { System.out.println("书写日志发生错误:" + e.toString()); } finally { try{ fw.close(); }catch (IOException e){ // TODO 自动生成 catch 块 e.printStackTrace(); } } }}