java追加文本到文件末尾
生活随笔
收集整理的這篇文章主要介紹了
java追加文本到文件末尾
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
public class Test {public static void main(String[] args) {method1("F:\\test.txt" , "測試測試將字符寫入文件默默"); }/** * 追加文件:使用FileOutputStream,在構(gòu)造FileOutputStream時,把第二個參數(shù)設(shè)為true * * @param fileName * @param content */ public static void method1(String file, String conent) { BufferedWriter out = null ; try { out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream(file, true ))); out.write(conent); } catch (Exception e) { e.printStackTrace();} finally { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } }
}
?
轉(zhuǎn)載于:https://www.cnblogs.com/lincj/p/5895763.html
總結(jié)
以上是生活随笔為你收集整理的java追加文本到文件末尾的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 全局变量引起的BUG
- 下一篇: python之tkinter图形界面