List of utility methods to do Zip Files
void | addToZipFile(String fileName, ZipOutputStream zos) add To Zip File System.out.println("Writing '" + fileName + "' to zip file"); File file = new File(fileName); FileInputStream fis = new FileInputStream(file); ZipEntry zipEntry = new ZipEntry(file.getName()); zos.putNextEntry(zipEntry); byte[] bytes = new byte[1024]; int length; while ((length = fis.read(bytes)) >= 0) { ... |
void | fileToZip(File file, File zipFile) file To Zip zipFile.createNewFile(); FileOutputStream fout = new FileOutputStream(zipFile); ZipOutputStream zout = null; try { zout = new ZipOutputStream(new BufferedOutputStream(fout)); if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) ... |
void | fileToZipFile(File toZip, File output) file To Zip File byte[] buffer = new byte[1024]; try { FileOutputStream fos = new FileOutputStream(output); ZipOutputStream zos = new ZipOutputStream(fos); ZipEntry ze = new ZipEntry(toZip.getName()); zos.putNextEntry(ze); FileInputStream in = new FileInputStream(toZip); int len; ... |
void | makeZip(File dir, File zipFile) make Zip JarOutputStream jos = new JarOutputStream(new FileOutputStream(zipFile)); String as[] = dir.list(); if (as != null) { for (int i = 0; i < as.length; i++) recurseFiles(jos, new File(dir, as[i]), ""); jos.close(); |
void | makeZip(String[] inFilePaths, String zipFilePath) make Zip File[] inFiles = new File[inFilePaths.length]; for (int i = 0; i < inFilePaths.length; i++) { inFiles[i] = new File(inFilePaths[i]); makeZip(inFiles, zipFilePath); |
byte[] | makeZipBinary(Map make Zip Binary ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(baos); try { for (String fileNameKey : instance.keySet()) { String fileName = fileNameKey.split(fileNameSeperator)[0]; ZipEntry ze = new ZipEntry(fileName); zos.putNextEntry(ze); zos.write(instance.get(fileNameKey)); ... |