Back to project page android-pkpass-viewer.
The source code is released under:
MIT License
If you think the Android project android-pkpass-viewer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.manso.mytickets.services; //w ww . ja v a 2 s .c o m import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.json.simple.parser.ParseException; import android.content.Context; import com.manso.mytickets.utils.RandomNameGenerator; public class PassStorageService { Context context; public PassStorageService(Context context) { super(); this.context = context; } public File InflatePkPassInTempDir(InputStream pkpassFile) throws IOException, ParseException { File cacheDir = context.getCacheDir(); String name = new RandomNameGenerator().randomName(); File inflateHere = new File(cacheDir, name); inflateHere.mkdir(); byte[] buffer = new byte[1024]; ZipInputStream zis = new ZipInputStream(pkpassFile); ZipEntry ze = zis.getNextEntry(); while (ze != null) { File newFile = new File(inflateHere, ze.getName()); FileOutputStream stream = new FileOutputStream(newFile); int len; while ((len = zis.read(buffer)) > 0) { stream.write(buffer, 0, len); } stream.close(); ze = zis.getNextEntry(); } zis.close(); return inflateHere; } }