如何在 SD 卡上创建的文本文件中插入换行符?

发布于 2024-09-14 07:31:24 字数 406 浏览 0 评论 0原文

我的代码非常标准。 sReport 包含我想要输出到文本文件的文本,并且它包含几个“\n”换行符,这些换行符在文本视图中渲染良好,但在文本文件中它们不存在。一定有一些简单的东西我错过了..

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

My code is pretty standard.. sReport contains the text I would like output to the text file, and it contains several "\n" line breaks that render fine in a textview, but in the text file they're non-existent. There must be something easy i'm missing..

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

御守 2024-09-21 07:31:24

请查看此内容并牢记 Android是基于Linux的。

please review this and keep in mind Android is Linux based.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文