Android Utililty Methods Zip File Create

List of utility methods to do Zip File Create

Description

The list of methods to do Zip File Create are organized into topic(s).

Method

voidzipIt(File zipFile, ArrayList files, Context context)
Zips all files specified in an ArrayList into a given file
byte[] buffer = new byte[1024];
FileOutputStream fos = new FileOutputStream(zipFile);
ZipOutputStream zos = new ZipOutputStream(fos);
assert context.getFilesDir() != null;
for (File file : files) {
    ZipEntry ze = new ZipEntry(file.getName());
    zos.putNextEntry(ze);
    FileInputStream in = new FileInputStream(file);
...
voidZipFiles(File zip, File... srcFiles)
Zip Files
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zip));
ZipFiles(out, "backup", srcFiles);
out.close();
voidcreateZip(String[] files, String zipFile)
create Zip
try {
    FileOutputStream dest = new FileOutputStream(zipFile);
    ZipOutputStream out = new ZipOutputStream(
            new BufferedOutputStream(dest));
    for (String s : files) {
        File file = new File(s);
        if (file.isDirectory()) {
            zipSubFolder(out, file, file.getParent().length());
...
voidcreateZip(String[] files, String zipFile)
create Zip
try {
    FileOutputStream dest = new FileOutputStream(zipFile);
    ZipOutputStream out = new ZipOutputStream(
            new BufferedOutputStream(dest));
    for (String s : files) {
        File file = new File(s);
        if (file.isDirectory()) {
            zipSubFolder(out, file, file.getParent().length());
...
voidcompress(File file)
compress
compress(file, true);
voidcompress(File file)
compress
compress(file, true);
voidcompress(File file, boolean delete)
compress
FileInputStream fis = new FileInputStream(file);
FileOutputStream fos = new FileOutputStream(file.getPath() + EXT);
compress(fis, fos);
fis.close();
fos.flush();
fos.close();
if (delete) {
    file.delete();
...
voidcompress(File file, boolean delete)
compress
FileInputStream fis = new FileInputStream(file);
FileOutputStream fos = new FileOutputStream(file.getPath() + EXT);
compress(fis, fos);
fis.close();
fos.flush();
fos.close();
if (delete) {
    file.delete();
...
voidcompressToFile(File dest, String str)
compress To File
if (str == null) {
    return;
GZIPOutputStream zipOut = null;
try {
    zipOut = new GZIPOutputStream(new FileOutputStream(dest));
    zipOut.write(str.getBytes());
} finally {
...