1
每个字线我能够访问我使用这个代码保存到文件中的Android从EDITTEXT输入的每一个字创建的文件。但是,输入更多的单词后,只有最后一个单词写在文件上。按下SAVE按钮后,似乎以前的单词被覆盖。每次在文本文件中保存一个单词时都会点击该按钮。我想列出在文本文件中逐行输入的单词。应该做什么来做到这一点?写在文本文件上的文本或字符串与前一个单词重叠。它应该写一行
这里是我使用的代码。
File dir = new File (getFilesDir(), "myFolder");
dir.mkdirs();
File file = new File(dir, "myData.txt");
try {
FileOutputStream f = new FileOutputStream(file);
PrintWriter pw = new PrintWriter(f);
pw.println("\n" + stringWord);
pw.flush();
pw.close();
f.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
感谢您指出了这一点。 =) – chArm 2013-02-20 23:31:04