我正在尝试将文本写入txt.file。
myOutWriter.append
我使用这种方法,但如果我这样做,我会丢失我的第一个值。每次我看到文本文件 有1条记录。我该怎么办?
答案 0 :(得分:1)
试试这个:
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_APPEND);
fos.write(string.getBytes());
fos.close();
答案 1 :(得分:0)
您应该在追加模式下初始化FileWriter
。
FileWriter myOutWriter = new FileWriter(fileName, true);
然后追加应该无缝地工作。
祝你好运