【问题标题】:Create enter (new line) automaticly text file in android在android中自动创建输入(新行)文本文件
【发布时间】:2012-06-14 05:21:01
【问题描述】:

我在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());
    }
}

它没有导航到新行。

【问题讨论】:

  • 请改写您的帖子。您想将“一些”字符串写入文本文件吗?
  • 我无法读懂你的想法,请改写你的问题
  • 我的帖子已经改写了,希望你能得到它
  • 我怀疑您正在检查 ExternalStorage 的 canWrite 以及在数据文件夹中写入文件的位置?这是你的数据文件夹在哪里?内部存储还是外部存储?
  • @Dheeresh Singh,,, 哦天哪,我忘了谢谢

标签: android string file


【解决方案1】:

fw.write() 方法之前或之后使用fw.newLine() 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-05
    • 1970-01-01
    相关资源
    最近更新 更多