Android Open Source - FileManager Compress






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;
//from w  ww .j  a  va  2 s. com
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class Compress {

  private static final int BUFFER = 2048;

  private String[] _files;
  private String _zipFile;

  public Compress(String[] files, String zipFile) {
    _files = files;
    _zipFile = zipFile;
  }

  public void zip(String location) {
    try {
      BufferedInputStream origin = null;
      FileOutputStream dest = new FileOutputStream(_zipFile);

      ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
          dest));

      byte data[] = new byte[BUFFER];

      for (int i = 0; i < _files.length; i++) {
        
        FileInputStream fi = new FileInputStream(_files[i]);
        origin = new BufferedInputStream(fi, BUFFER);
        ZipEntry entry = new ZipEntry(_files[i].substring(_files[i]
            .lastIndexOf(location) + 1));
        out.putNextEntry(entry);
        int count;
        while ((count = origin.read(data, 0, BUFFER)) != -1) {
          out.write(data, 0, count);
        }
        origin.close();
      }

      out.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}




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