【问题标题】:Trying to figure out how to write an array out to a file stream in Android试图弄清楚如何将数组写入Android中的文件流
【发布时间】:2011-09-22 18:07:05
【问题描述】:

在我在模拟器上的应用程序中,保存一个 48k 长的文件大约需要 20 秒。现在我正在逐字节保存。使用文件流,FileOutputStream 写入函数。 看起来像 fos.write(cGlobals.board.BitMap[c++]);

我尝试这样做,但出现编译错误,提示参数无效 fos.write(cGlobals.board.BitMap); 有没有更好的方法来逐个字节地做到这一点? 泰德

【问题讨论】:

    标签: android file stream


    【解决方案1】:

    围绕您的 FileOutputStream 创建一个 BufferredOutputStream

    FileOutputStream fileOutputStream = new FileOutputStream(.....);
    OutputStream bos = new BufferedOutputStream(fileOutputStream, 8192);
    try {
       ... do your stuff using bos instead of fileOutputStream
    } finally {
       bos.close();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-31
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 2021-08-27
      • 2020-08-27
      • 1970-01-01
      相关资源
      最近更新 更多