List of utility methods to do Zip Directory
void | addDirectoryToZip(File directory, File base, String dirPrefix, ZipOutputStream zos) Recursively inserts all files in a directory into a zipstream. if (base == null) base = directory; if (dirPrefix == null) dirPrefix = ""; if (!base.equals(directory) && directory.list().length == 0) { String dirEntryPath = dirPrefix + directory.getPath().substring(base.getPath().length() + 1).replace('\\', '/'); ZipEntry dirEntry = new ZipEntry(dirEntryPath.endsWith("/") ? dirEntryPath : dirEntryPath + "/"); ... |
void | addDirectoryToZip(ZipOutputStream out, File dir, String prefix) add Directory To Zip FileInputStream in; byte[] buf = new byte[1024]; int len; if (dir.isDirectory()) { for (File f : dir.listFiles()) { if (f.isDirectory()) { addDirectoryToZip(out, f, ("".equals(prefix) ? "" : prefix + "/") + f.getName()); } else if (f.isFile()) { ... |
void | addDirectoryToZip(ZipOutputStream zipOutputStream, File dirToZip, String basePath, File fileToExclude) Add the content of a directory recursively to the zip. for (File file : dirToZip.listFiles()) { if (file.isDirectory()) { addDirectoryToZip(zipOutputStream, file, basePath, fileToExclude); } else if (!file.equals(fileToExclude)) { addFileToZip(zipOutputStream, file, basePath); |
void | addDirectoryToZip(ZipOutputStream zipOutputStream, String dirName) Adds a directory to a .zip file zipOutputStream.putNextEntry(new ZipEntry(dirName));
zipOutputStream.closeEntry();
|
void | addDirToArchive(ZipOutputStream zop, File srcFile) Helper method that aids zipRollbackPackage in recursively creating a zip file from a directory's contents. File[] files = srcFile.listFiles(); for (File file : files) { if (file.isDirectory()) { addDirToArchive(zop, file); continue; byte[] buffer = new byte[1024]; FileInputStream fis = new FileInputStream(file); ... |
void | addDirToArchive(ZipOutputStream zos, File srcFile) Adds file / folder to zip output stream. File[] files = srcFile.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { addDirToArchive(zos, files[i]); continue; try { byte[] buffer = new byte[1024]; ... |
void | addDirToArchive(ZipOutputStream zos, String path, File initialDir) Add a directory to a ZIP archive File srcDir = new File(path); File[] files = srcDir.listFiles(); for (int i = 0; i < files.length; i++) { try { String relativePath = initialDir.toURI().relativize(files[i].toURI()).getPath(); zos.putNextEntry(new ZipEntry(relativePath)); boolean emptyDir = files[i].isDirectory() && files[i].length() == 0; if (!emptyDir) { ... |
void | zip(File dir, File base, ZipOutputStream out) zip File[] files = dir.listFiles(); byte[] buffer = new byte[8192]; final String FILE_SEP = System.getProperty("file.separator"); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { zip(files[i], base, out); } else { FileInputStream fin = new FileInputStream(files[i]); ... |
void | zip(File dir, ZipOutputStream out, String prefix) zip File[] files = dir.listFiles(); for (File f : files) { if (f.isFile()) { BufferedInputStream bis = null; try { bis = new BufferedInputStream(new FileInputStream(f)); ZipEntry entry = new ZipEntry(prefix + f.getName()); out.putNextEntry(entry); ... |
void | zip(File dir2zip, File zipFile) zip ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)); internalZipDir(dir2zip.getAbsolutePath(), dir2zip.getAbsolutePath(), zos); zos.close(); |