Topic: 写文件问题... |
Print this page |
1.写文件问题... | Copy to clipboard |
Posted by: 小尘尘 Posted on: 2005-11-22 00:03 各位大侠,在文本文件的最后增加一行,怎么加? 比如 我先前写了一行 abc 我现在要在abc后面换行,然后新写一行 abc def 怎么做呀?? 谢谢 |
2.Re:写文件问题... [Re: 小尘尘] | Copy to clipboard |
Posted by: onsofts Posted on: 2005-11-22 04:10 FileOutputStream appendedFile = new FileOutputStream ("c:\\autoexec.bat", true); |
3.Re:写文件问题... [Re: 小尘尘] | Copy to clipboard |
Posted by: 小尘尘 Posted on: 2005-11-22 21:06 大侠,这个我知道.... 是要在文件末尾加一行... 要怎么做? 谢拉 |
4.Re:写文件问题... [Re: 小尘尘] | Copy to clipboard |
Posted by: arroyo Posted on: 2005-11-23 14:58 加个换行符"\r\n"(windows环境) |
5.Re:写文件问题... [Re: 小尘尘] | Copy to clipboard |
Posted by: Infinite Posted on: 2005-11-23 21:25 // WriteFile example import java.io.*; public class WriteFile { public static void main(String[] args) throws IOException { InputStreamReader in=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(in); FileWriter fw=new FileWriter(new File("1.txt")); BufferedWriter bw=new BufferedWriter(fw); String s ; while(true) { System.out.println("please input a string:"); s=br.readLine(); if(s.length()==0) break; else bw.write( s ); bw.newLine(); } bw.close(); } } ======================================= 小尘尘 wrote: |
6.Re:写文件问题... [Re: 小尘尘] | Copy to clipboard |
Posted by: 小尘尘 Posted on: 2005-11-25 23:21 非常感谢onsofts ,onsofts 和Infinite !!! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |