Android Zip File Create compressToFile(File dest, String str)

Here you can find the source of compressToFile(File dest, String str)

Description

compress To File

Declaration

public static void compressToFile(File dest, String str)
            throws IOException 

Method Source Code

//package com.java2s;
import java.io.*;
import java.util.zip.GZIPOutputStream;

public class Main {
    public static void compressToFile(File dest, String str)
            throws IOException {
        if (str == null) {
            return;
        }/* w w w .  j  av  a  2s.  com*/

        GZIPOutputStream zipOut = null;

        try {
            zipOut = new GZIPOutputStream(new FileOutputStream(dest));
            zipOut.write(str.getBytes());
        } finally {
            if (zipOut != null) {
                try {
                    zipOut.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

Related

  1. createZip(String[] files, String zipFile)
  2. compress(File file)
  3. compress(File file)
  4. compress(File file, boolean delete)
  5. compress(File file, boolean delete)