我在 android 中创建了一个文件应用程序,我想将一个字符串变量写入file.txt
,它应该自动插入一个enter
(导航到新行)
我用了:
public void cekFile() {
File root = Environment.getExternalStorageDirectory();
try {
BufferedWriter fw = new BufferedWriter(new FileWriter(new File(
"/data/log/log.txt"), true));
if (root.canWrite()) {
fw.write("Monitoring Panggilan" + "\n");
fw.close();
}
} catch (IOException e) {
Log.e("One", "Could not write file " + e.getMessage());
}
}
它不是导航到新行。