最後,做我原本計劃的內容太多了!相反,我最終只得到一個ZipEntry,但只有那個我想要的方式,它不必每次都循環遍歷每一個。
public Bitmap getBitmapFromZip(final String zipFilePath, final String imageFileInZip){
Bitmap result = null;
try {
ZipEntry ze = zipfile.getEntry(imageFileInZip);
InputStream in = zipfile.getInputStream(ze);
result = BitmapFactory.decodeStream(in);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
就必須通過快速循環的開頭把所有的名字
public ArrayList<String> unzip() {
ArrayList<String> fnames = ArrayList<String>();
try {
FileInputStream fin = new FileInputStream(_zipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
if(ze.isDirectory()) {
} else {
fnames.add(ze.getName()/*fname[fname.length - 1]*/);
zin.closeEntry();
}
}
zin.close();
} catch(Exception e) {
}
return fnames;
}
我發現把圖像轉換成位圖陣列的一種方式,但它永遠無法得到通過在第四或第五的整個壓縮或東西的形象它總是在BitmapFactory.decodeStream(zis)期間崩潰; – tantonj 2012-03-20 04:00:47