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

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

        <tfoot id='Bi727'></tfoot>
      1. <legend id='Bi727'><style id='Bi727'><dir id='Bi727'><q id='Bi727'></q></dir></style></legend>

        如何加快 Java/Android 中的解压缩时间?

        How to speed up unzipping time in Java / Android?(如何加快 Java/Android 中的解压缩时间?)
          • <bdo id='U22EB'></bdo><ul id='U22EB'></ul>
            <i id='U22EB'><tr id='U22EB'><dt id='U22EB'><q id='U22EB'><span id='U22EB'><b id='U22EB'><form id='U22EB'><ins id='U22EB'></ins><ul id='U22EB'></ul><sub id='U22EB'></sub></form><legend id='U22EB'></legend><bdo id='U22EB'><pre id='U22EB'><center id='U22EB'></center></pre></bdo></b><th id='U22EB'></th></span></q></dt></tr></i><div id='U22EB'><tfoot id='U22EB'></tfoot><dl id='U22EB'><fieldset id='U22EB'></fieldset></dl></div>

              • <tfoot id='U22EB'></tfoot>
                  <tbody id='U22EB'></tbody>

                  <legend id='U22EB'><style id='U22EB'><dir id='U22EB'><q id='U22EB'></q></dir></style></legend>

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

                1. 本文介绍了如何加快 Java/Android 中的解压缩时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 android 上解压缩文件似乎非常慢.起初我以为这只是模拟器,但在手机上似乎是一样的.我尝试了不同的压缩级别,最终下降到存储模式,但仍然需要很长时间.

                  Unzipping files on android seems to be dreadfully slow. At first I thought this was just the emulator but it appears to be the same on the phone. I've tried different compression levels, and eventually dropped down to storage mode but it still takes ages.

                  总之,一定是有原因的!还有其他人有这个问题吗?我的解压方法是这样的:

                  Anyway, there must be a reason! Does anyone else have this problem? My unzip method looks like this:

                  public void unzip()
                  {
                  try{
                          FileInputStream fin = new FileInputStream(zipFile);
                          ZipInputStream zin = new ZipInputStream(fin);
                          File rootfolder = new File(directory);
                          rootfolder.mkdirs();
                          ZipEntry ze = null;
                          while ((ze = zin.getNextEntry())!=null){
                  
                              if(ze.isDirectory()){
                                  dirChecker(ze.getName());
                              }
                              else{
                                  FileOutputStream fout = new FileOutputStream(directory+ze.getName());
                  
                              for(int c = zin.read();c!=-1;c=zin.read()){
                                  fout.write(c);
                              }
                                  //Debug.out("Closing streams");
                                  zin.closeEntry();
                                  fout.close();
                  
                          }
                      }
                      zin.close();
                  }
                  catch(Exception e){
                              //Debug.out("Error trying to unzip file " + zipFile);
                  
                  }
                      }
                  

                  推荐答案

                  我不知道在 Android 上解压缩是否很慢,但是在循环中逐字节复制肯定会更慢.尝试使用 BufferedInputStream 和 BufferedOutputStream - 它可能会更复杂一些,但根据我的经验,这最终是值得的.

                  I don't know if unzipping on Android is slow, but copying byte for byte in a loop is surely slowing it down even more. Try using BufferedInputStream and BufferedOutputStream - it might be a bit more complicated, but in my experience it is worth it in the end.

                  BufferedInputStream in = new BufferedInputStream(zin);
                  BufferedOutputStream out = new BufferedOutputStream(fout);
                  

                  然后你可以这样写:

                  byte b[] = new byte[1024];
                  int n;
                  while ((n = in.read(b,0,1024)) >= 0) {
                    out.write(b,0,n);
                  }
                  

                  这篇关于如何加快 Java/Android 中的解压缩时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Lucene Porter Stemmer not public(Lucene Porter Stemmer 未公开)
                  How to index pdf, ppt, xl files in lucene (java based or python or php any of these is fine)?(如何在 lucene 中索引 pdf、ppt、xl 文件(基于 java 或 python 或 php 中的任何一个都可以)?)
                  KeywordAnalyzer and LowerCaseFilter/LowerCaseTokenizer(KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer)
                  How to search between dates (Hibernate Search)?(如何在日期之间搜索(休眠搜索)?)
                  How to get positions from a document term vector in Lucene?(如何从 Lucene 中的文档术语向量中获取位置?)
                  Java Lucene 4.5 how to search by case insensitive(Java Lucene 4.5如何按不区分大小写进行搜索)

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

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

                    <tbody id='kIW95'></tbody>

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