mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
個人BLOG
it developer
  1. Main page
  2. dev
  3. Main content

ZipFile.getEntry 无法获得内容

2012-02-03 103hotness 0likes 0comments

最近android上做660多MB的zip文件中解压缩wav文件


ZipEntry zipEntry = zipFile.getEntry(entryName);
发现上面的方法始终null

但文件时的确存在的,于是在市场上下载各种zipapp 打开zip文件后,发现里面部分文件夹丢失
费解,于是上网咕咕噜

http://stackoverflow.com/questions/8653283/reading-a-huge-zip-file-in-java-out-of-memory-error

It is very unlikley that you get an out of memory exception because of processing a ZIP file. The Java classes ZipFile and ZipEntry don't contain anything that could possibly fill up 613 MB of memory.


What could exhaust your memory is to keep the decompressed files of the ZIP archive in memory, or - even worse - keeping them as an XML DOM, which is very memory intensive.


Switching to another ZIP library will hardly help. Instead, you should look into changing your code so that it processes the ZIP archive and the contained files like streams and only keeps a limited part of each file in memory at a time.


BTW: I would be nice if you could provide more information about the huge ZIP files (do they contain many small files or few large files?) and about what you do with each ZIP entry.


Update:


Thanks for the additional information. It looks like you keep the contents of the ZIP file in memory (although it somewhat depends on the implementation of the S3Object class, which I don't know).


It's probably best to implement some sort of batching as you propose yourself. You could for example add up the decompressed size of each ZIP entry and upload the files every time the total size exceeds 100 MB.


--------------------------------


上面的是java上的原因,android 上不知道是不是也是这个原因.

目前没找到解决方案.

Tag: Nothing
Last updated:2012-02-03

mikebai

This person is a lazy dog and has left nothing

Like
< Last article
Next article >

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang