Android Open Source - FileManager Decompress






From Project

Back to project page FileManager.

License

The source code is released under:

GNU General Public License

If you think the Android project FileManager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ankur.coreutils;
/* www . java  2  s . c o  m*/
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

/**
 * 
 * @author jon
 */

public class Decompress {
  private String _zipFile;
  private String _location;

  public Decompress(String zipFile, String location) {
    _zipFile = zipFile;
    _location = location;
  }

  public void unzip() {
    try {

      File fSourceZip = new File(_zipFile);
      // File temp = new File(zipPath);
      // temp.mkdir();

      /*
       * Extract entries while creating required sub-directories
       */
      ZipFile zipFile = new ZipFile(fSourceZip);
      Enumeration<?> e = zipFile.entries();

      while (e.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) e.nextElement();
        File destinationFilePath = new File(_location, entry.getName());

        // create directories if required.
        destinationFilePath.getParentFile().mkdirs();

        // if the entry is directory, leave it. Otherwise extract it.
        if (entry.isDirectory()) {
          continue;
        } else {

          /*
           * Get the InputStream for current entry of the zip file
           * using
           * 
           * InputStream getInputStream(Entry entry) method.
           */
          BufferedInputStream bis = new BufferedInputStream(
              zipFile.getInputStream(entry));

          int b;
          byte buffer[] = new byte[1024];

          /*
           * read the current entry from the zip file, extract it and
           * write the extracted file.
           */
          FileOutputStream fos = new FileOutputStream(
              destinationFilePath);
          BufferedOutputStream bos = new BufferedOutputStream(fos,
              1024);

          while ((b = bis.read(buffer, 0, 1024)) != -1) {
            bos.write(buffer, 0, b);
          }

          // flush the output stream and close it.
          bos.flush();
          bos.close();

          // close the input stream.
          bis.close();
        }
      }
    } catch (IOException ioe) {
    }
  }
}




Java Source Code List

com.ankur.core.AppManager.java
com.ankur.core.DirectoryInfo.java
com.ankur.core.EventHandler.java
com.ankur.core.FileUtils.java
com.ankur.core.InfoDialog.java
com.ankur.core.Main.java
com.ankur.core.Settings.java
com.ankur.coreutils.Bookmarks.java
com.ankur.coreutils.CheckBoxActivity.java
com.ankur.coreutils.ClearSearchSuggestions.java
com.ankur.coreutils.Compress.java
com.ankur.coreutils.Decompress.java
com.ankur.coreutils.ImagePreview.java
com.ankur.coreutils.LinuxShell.java
com.ankur.coreutils.SearchSuggestions.java
com.ankur.coreutils.VideoPreview.java