<i id='IeuvB'><tr id='IeuvB'><dt id='IeuvB'><q id='IeuvB'><span id='IeuvB'><b id='IeuvB'><form id='IeuvB'><ins id='IeuvB'></ins><ul id='IeuvB'></ul><sub id='IeuvB'></sub></form><legend id='IeuvB'></legend><bdo id='IeuvB'><pre id='IeuvB'><center id='IeuvB'></center></pre></bdo></b><th id='IeuvB'></th></span></q></dt></tr></i><div id='IeuvB'><tfoot id='IeuvB'></tfoot><dl id='IeuvB'><fieldset id='IeuvB'></fieldset></dl></div>

    <tfoot id='IeuvB'></tfoot>
    • <bdo id='IeuvB'></bdo><ul id='IeuvB'></ul>

    <legend id='IeuvB'><style id='IeuvB'><dir id='IeuvB'><q id='IeuvB'></q></dir></style></legend>
    1. <small id='IeuvB'></small><noframes id='IeuvB'>

      1. 安卓文件拷贝

        时间:2024-04-15
          <bdo id='0nNTm'></bdo><ul id='0nNTm'></ul>
          <legend id='0nNTm'><style id='0nNTm'><dir id='0nNTm'><q id='0nNTm'></q></dir></style></legend>
            <tbody id='0nNTm'></tbody>

          <small id='0nNTm'></small><noframes id='0nNTm'>

              <i id='0nNTm'><tr id='0nNTm'><dt id='0nNTm'><q id='0nNTm'><span id='0nNTm'><b id='0nNTm'><form id='0nNTm'><ins id='0nNTm'></ins><ul id='0nNTm'></ul><sub id='0nNTm'></sub></form><legend id='0nNTm'></legend><bdo id='0nNTm'><pre id='0nNTm'><center id='0nNTm'></center></pre></bdo></b><th id='0nNTm'></th></span></q></dt></tr></i><div id='0nNTm'><tfoot id='0nNTm'></tfoot><dl id='0nNTm'><fieldset id='0nNTm'></fieldset></dl></div>
              • <tfoot id='0nNTm'></tfoot>
                  本文介绍了安卓文件拷贝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我发现从 SD 卡上的文本文件一次读取一行非常慢.我想如果文件在内部存储器中可能会更快,所以我想将文件从 SD 卡复制到内部存储器.

                  I am finding that reading one line at a time from a text file on the SD card is rather slow. I imagine that it might be quicker if the file is in internal memory, so I want to copy files from the SD card to internal storage.

                  我可以在网上找到的文件复制示例似乎涉及一次将一个字节从 InputStream 复制到 OutputStream 或从 FileReader 复制到 FileWriter.这真的是最快最有效的方法吗?

                  The file copy examples I can find on the web seem to involve copying one byte at a time from an InputStream to an OutputStream or from a FileReader to a FileWriter. Is this really the quickest and most efficient method?

                  推荐答案

                  如果您将文件拉入应用程序中,我建议您做的是读取数据,然后将您收集的内存数据填充到一些一种阅读器(也许是 BufferedReader),这样您就可以从那里阅读这些行.

                  If you are pulling the file in for use in your application what I suggest you do is read in the data then stuff the in memory data you have collected into some kind of reader (BufferedReader perhaps) so that you can then read the lines from there.

                  这是我通常做的一个例子:

                  Here is an example of what I typically do:

                  // Assumption: I already have the file object I want to read
                  // Note: I'm not doing any error handling.
                  InputStream input = new FileInputStream(file);
                  ByteArrayOutputStream baos = new ByteArrayOutputStream();
                  byte[] buffer = new byte[1024];
                  int bytesRead = 0;
                  while( (bytesRead = input.read(buffer)) > 0){
                      baos.write(buffer, 0, bytesRead);
                  }
                  StringReader stringReader = new StringReader( new String(baos.toByteArray()) );
                  BufferedReader bufferedReader = new BufferedReader( stringReader );
                  for(String line : bufferedReader.readLine()){
                      // TODO: Handle each line appropriately or something
                      Log.d("Reading Data Example", line);
                  }
                  

                  这篇关于安卓文件拷贝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C) 下一篇:在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中

                  相关文章

                    <bdo id='KRzVR'></bdo><ul id='KRzVR'></ul>
                  1. <tfoot id='KRzVR'></tfoot>
                    <legend id='KRzVR'><style id='KRzVR'><dir id='KRzVR'><q id='KRzVR'></q></dir></style></legend>
                    <i id='KRzVR'><tr id='KRzVR'><dt id='KRzVR'><q id='KRzVR'><span id='KRzVR'><b id='KRzVR'><form id='KRzVR'><ins id='KRzVR'></ins><ul id='KRzVR'></ul><sub id='KRzVR'></sub></form><legend id='KRzVR'></legend><bdo id='KRzVR'><pre id='KRzVR'><center id='KRzVR'></center></pre></bdo></b><th id='KRzVR'></th></span></q></dt></tr></i><div id='KRzVR'><tfoot id='KRzVR'></tfoot><dl id='KRzVR'><fieldset id='KRzVR'></fieldset></dl></div>

                    <small id='KRzVR'></small><noframes id='KRzVR'>