List of utility methods to do Zip Folder
File | doZip(File fileIn, String fileOut) do Zip if (fileIn == null || !fileIn.exists()) return null; ZipOutputStream out = new ZipOutputStream(new FileOutputStream(fileOut)); FileInputStream in = new FileInputStream(fileIn); out.putNextEntry(new ZipEntry(fileIn.getName())); int len; byte[] buf = new byte[1024]; while ((len = in.read(buf)) > 0) { ... |
long | doZip(Map Zip up a bunch of files. TreeMap<String, File> sortedStructure = new TreeMap<String, File>(); sortedStructure.putAll(zipStructure); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile)); out.setComment("created with my program"); out.setMethod(ZipOutputStream.DEFLATED); out.setLevel(Deflater.DEFAULT_COMPRESSION); byte[] buf = new byte[1024 * 10]; for (String key : sortedStructure.keySet()) { ... |
boolean | doZip(Properties properties, String name, File f) same as above given a .zip or .jar file object. ZipInputStream zip; try { zip = new ZipInputStream(new FileInputStream(f)); } catch (FileNotFoundException x) { return false; boolean result = false; ZipEntry ze; ... |
void | doZip(String baseDir, String fileName) do Zip List fileList = getSubFiles(new File(baseDir)); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(fileName)); ZipEntry ze = null; byte[] buf = new byte[1024]; int readLen = 0; for (int i = 0; i < fileList.size(); i++) { File f = (File) fileList.get(i); ze = new ZipEntry(getAbsFileName(baseDir, f)); ... |
void | doZip(String filename, String zipFileName) This the compress xml file request and respone File f = new File(filename); FileInputStream fis = null; ZipOutputStream zipOutputStream = null; try { if (f.exists()) { int size = (int) f.length(); byte[] buf = new byte[size]; fis = new FileInputStream(f.getAbsolutePath()); ... |
void | doZip(String inFilePath, String outFilePath) do Zip try { File inFile = new File(inFilePath); ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(outFilePath)); zipFile(zipOut, inFile, ""); zipOut.close(); } catch (IOException ioe) { ioe.printStackTrace(); |
void | doZipFile(ZipOutputStream zipOut, File file, String dirPath) do Zip File if (file.isFile()) { BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); String zipName = file.getPath().substring(dirPath.length()); while (zipName.charAt(0) == '\\' || zipName.charAt(0) == '/') { zipName = zipName.substring(1); ZipEntry entry = new ZipEntry(zipName); zipOut.putNextEntry(entry); ... |
void | zip(File rootDir, String zipPath) zip ZipOutputStream zip = null; try { File zipFile = new File(zipPath); if (zipFile.exists()) { if (!delete(zipFile)) throw new IOException("Could not delete " + zipPath); int timeToWait = 1000; waitAtLeast(timeToWait); ... |
void | zip(File rootDir, String zipPath) zip ZipOutputStream zip = null; try { File zipFile = new File(zipPath); if (zipFile.exists()) { if (!delete(zipFile)) throw new IOException("Could not delete " + zipPath); int timeToWait = 1000; waitAtLeast(timeToWait); ... |
void | zipDir(File dir, String classPackage, String zipFile) zip Dir File[] files = dir.listFiles(); if (files != null) { ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)); ZipEntry ze = null; byte[] buf = new byte[1024]; int readLen = 0; for (int i = 0; i < files.length; i++) { File file = files[i]; ... |