/** * Zip the subdirectory and exclude already zipped files * @param path * @param srcFolder * @param zip * @param includeFullPath * @throws IOException */ static private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip, boolean includeFullPath) throws IOException { File folder = new File(srcFolder); for (String fileName : folder.list()) { if (path.equals("") && !fileName.endsWith(".zip")) { if (includeFullPath){ addFileToZip(folder.toString(), srcFolder + "/" + fileName, zip); } else { addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip); } } else if (!fileName.endsWith(".zip")) { addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip); } } }