實例如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
private static string savefile = "e:\\test.txt" ; private static void saveasfilewriter(string content) { filewriter fwriter = null ; try { fwriter = new filewriter(savefile); fwriter.write(content); } catch (ioexception ex) { ex.printstacktrace(); } finally { try { fwriter.flush(); fwriter.close(); } catch (ioexception ex) { ex.printstacktrace(); } } } |
以上這篇java 實現將一個string保存到txt文檔中就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/baoyan2015/article/details/53203370