Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. public boolean mUnpackZipFile(String mArchivePath,String mOutPutStream) {
  2. InputStream inputstream;
  3. ZipInputStream zipinputstream;
  4. Message msg;
  5.  
  6. try {
  7. String filename;
  8. inputstream = new FileInputStream(mArchivePath);
  9. zipinputstream = new ZipInputStream(new BufferedInputStream(inputstream));
  10. ZipEntry mZipEntry;
  11. byte[] buffer = new byte[1024];
  12. int count;
  13.  
  14. while ((mZipEntry = zipinputstream.getNextEntry()) != null) {
  15. filename = mZipEntry.getName();
  16.  
  17. if (mZipEntry.isDirectory()) {
  18. File fmd = new File(mOutPutStream + filename);
  19. fmd.mkdirs();
  20. continue;
  21. }
  22.  
  23. FileOutputStream fileoutputstream = new FileOutputStream(mOutPutStream + filename);
  24.  
  25. msg = h.obtainMessage(FILE_NAME, filename);
  26. h.sendMessage(msg);
  27.  
  28. while ((count = zipinputstream.read(buffer)) != -1) {
  29. fileoutputstream.write(buffer, 0, count);
  30. }
  31. fileoutputstream.close();
  32. zipinputstream.closeEntry();
  33. }
  34.  
  35. zipinputstream.close();
  36. } catch (IOException e) {
  37. e.printStackTrace();
  38. return false;
  39. }
  40.  
  41. return true;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement