List of utility methods to do Zip File
void | zip(File[] sourceFiles, File destFile, boolean deleteOriginalFiles) zip zip(sourceFiles, destFile, deleteOriginalFiles, false); |
void | zip(final File dir, final File target) zip if (target.exists()) { delete(target); final ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(target)); try { zipDir(target, zip, dir, ""); } finally { try { ... |
void | zip(final File tempLocation, final File targetZipFile) Zip a list of file into one zip file. File[] files = tempLocation.listFiles(); int fileLength = files.length; try { FileOutputStream fos = new FileOutputStream(targetZipFile); ZipOutputStream zos = new ZipOutputStream(fos); byte[] buffer = new byte[128]; for (int i = 0; i < fileLength; i++) { File currentFile = files[i]; ... |
void | zip(final File zipFile, final File... files) zip try (final FileOutputStream fos = new FileOutputStream(zipFile); final ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos))) { final byte[] data = new byte[BUFFER]; for (final File file : files) { try (final FileInputStream fis = new FileInputStream(file); final BufferedInputStream origin = new BufferedInputStream(fis, BUFFER)) { final ZipEntry entry = new ZipEntry(file.getName()); zos.putNextEntry(entry); ... |
boolean | zip(final File zipFile, final File[] files) compresses the specified files into a zip archive ZipOutputStream out = null; try { byte[] buffer = new byte[4096]; int bytesRead; out = new ZipOutputStream(new FileOutputStream(zipFile)); for (File f : files) { FileInputStream in = null; try { ... |
boolean | zip(final File[] filesToZip, final File zipFile) zip final byte[] buf = new byte[2048]; ZipOutputStream out = null; FileInputStream in = null; try { out = new ZipOutputStream(new FileOutputStream(zipFile)); for (int i = 0; i < filesToZip.length; ++i) { in = new FileInputStream(filesToZip[i]); out.putNextEntry(new ZipEntry(filesToZip[i].getName())); ... |
byte[] | zip(final Map zip final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ZipOutputStream zos = new ZipOutputStream(baos); try { for (final Entry<String, byte[]> file : files.entrySet()) { zos.putNextEntry(new ZipEntry(file.getKey())); zos.write(file.getValue()); zos.closeEntry(); return baos.toByteArray(); } finally { zos.close(); |
byte[] | zip(final String fileName, final byte[] fileContent) zip final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ZipOutputStream zos = new ZipOutputStream(baos); try { zos.putNextEntry(new ZipEntry(fileName)); zos.write(fileContent); } finally { zos.closeEntry(); zos.close(); ... |
void | zip(final String sourceFileDir, final String zipFile) Zip it final byte[] buffer = new byte[1024]; try (final FileOutputStream fos = new FileOutputStream(zipFile); final ZipOutputStream zos = new ZipOutputStream(fos)) { final List<File> fileList = new ArrayList<>(); generateFileList(new File(sourceFileDir), fileList); for (final File file : fileList) { final ZipEntry ze = new ZipEntry(file.getName()); zos.putNextEntry(ze); ... |
byte[] | zip(InputStream is) zip ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(bos); ZipEntry ze = new ZipEntry("X"); zos.putNextEntry(ze); pipe(is, zos); zos.closeEntry(); zos.flush(); zos.close(); ... |