public static void zip(File src, String destPath) throws IOException {
        FileOutputStream out = null;
        ZipOutputStream zout = null;
        try {
            File destFile = new File(destPath);
            destFile.createNewFile();
            out = new FileOutputStream(destFile);
            zout = new ZipOutputStream(out);
            if (src.isFile()) {
                ZipEntry entry = new ZipEntry(src.getName());
                zout.putNextEntry(entry);
                writeFile(src, zout);
                zout.closeEntry();
            } else {
                ArrayList<File> files = new ArrayList<File>();
                flatten(src, files);
                String parentPath = src.getAbsolutePath();
                for (File file : files) {
                    String name = file.getAbsolutePath().substring(parentPath.length()).replace(File.separator, "/");
                    if (name.startsWith("/")) {
                        name = name.substring(1);
                    }
                    if (file.isDirectory()) {
                        name += "/";
                    }
                    ZipEntry entry = new ZipEntry(name);
                    zout.putNextEntry(entry);
                    if (file.isFile()) {
                        writeFile(file, zout);
                    }
                    zout.closeEntry();
                }
            }
            zout.finish();
        } finally {
            if (zout != null) {
                zout.flush();
                zout.close();
            }
            if (out != null) {
                out.flush();
                out.close();
            }
        }
    }