【问题标题】:How do I insert line breaks into a text file i'm creating on the SD Card?如何在 SD 卡上创建的文本文件中插入换行符?
【发布时间】:2010-08-16 04:34:07
【问题描述】:

我的代码非常标准.. sReport 包含我想要输出到文本文件的文本,它包含几个“\n”换行符,可以在 textview 中很好地呈现,但在文本文件中它们不是存在的。一定有一些简单的东西我错过了..

    try {
        FileOutputStream fOut = new FileOutputStream(sDir + sFile);
        //write  
        fOut.write( sReport.getBytes() );
        // Close output stream
        fOut.flush();
        fOut.close();
    } catch (IOException  e) {
        e.printStackTrace();
    }

【问题讨论】:

  • 你用什么来查看sdcard上的文本文件?
  • 记事本.. 我只是想导出一个标准的 ascii 流,所以也许 FileOutputStream 不是我想要的?
  • 这不是 FileOutputStreamFaultm 我会说 naikus 是对的,可能 Windows 上的记事本没有正确显示中断。尝试在 \n 之后添加 \r。
  • 没错。记事本(或大多数 Windows 应用程序)无法正确显示,因为您需要不同的换行符

标签: android android-sdcard


【解决方案1】:

请查看this 并记住 Android 是基于 Linux 的。

【讨论】:

    猜你喜欢
    • 2018-01-02
    • 2018-05-18
    • 2020-03-05
    • 2016-04-18
    • 1970-01-01
    • 2023-03-13
    • 2012-10-08
    • 1970-01-01
    • 2012-09-20
    相关资源
    最近更新 更多