开发者

How to append to a text file in android?

开发者 https://www.devze.com 2023-02-25 07:35 出处:网络
FileWriter f; try { f = new FileWriter(Environment.getExternalStorageDirectory()+ \"/Text/o1\"+\".txt\");
FileWriter f;
try {
 f = new FileWriter(Environment.getExternalStorageDirectory()+
                 "/Text/o1"+".txt");
     f.write("Hello World");
 f.flush();
 f.close();
}

I can create a file and write to it using the above code. How do i ap开发者_Go百科pend to the text file without over writing it? thanks


Use FileWriter(File file,boolean append) constructor while creating FileWriter.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号