@Test public void createZipFile() throws Exception { File targetZip = new File(tmpDir + File.separator + "abc.zip"); doCreateZipFile(); assertTrue(targetZip.exists()); assertTrue(userHomeZip.exists()); targetZip.delete(); assertTrue(!targetZip.exists()); userHomeZip.delete(); assertTrue(!userHomeZip.exists()); }
public static File createZipFile(File[] files, File target, String encoding) { try { target.getParentFile().mkdirs(); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(target), Charset.forName(encoding)); for (int i = 0; i < files.length; i++) { fileZip(zos, files[i], ""); } zos.close(); } catch (Exception e) { throw new RuntimeException("Failed to process ZIP file.", e); } return target; }
RmZipHelper { public static File createZipFile(File[] files, File target, String encoding) { try { target.getParentFile().mkdirs(); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(target), Charset.forName(encoding)); for (int i = 0; i < files.length; i++) { fileZip(zos, files[i], ""); } zos.close(); } catch (Exception e) { throw new RuntimeException("Failed to process ZIP file.", e); } return target; } }
RmZipHelper { public static File createZipFile(File[] files, File target, String encoding) { try { target.getParentFile().mkdirs(); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(target), Charset.forName(encoding)); for (int i = 0; i < files.length; i++) { fileZip(zos, files[i], ""); } zos.close(); } catch (Exception e) { throw new RuntimeException("Failed to process ZIP file.", e); } return target; }  }
RmZipHelper { public static File createZipFile(File[] files, File target, String encoding) { try { target.getParentFile().mkdirs(); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(target), Charset.forName(encoding)); for (int i = 0; i < files.length; i++) { fileZip(zos, files[i], ""); } zos.close(); } catch (Exception e) { throw new RuntimeException("Failed to process ZIP file.", e); } return target; }  static File createZipFile(File[] files, File target, String encoding); static void unZip(String zipFile, String directory, String encoding); static void extractFile(ZipFile archive, String extractDir); static File getExcelFromFile(File zipFile); }
RmZipHelper { public static File createZipFile(File[] files, File target, String encoding) { try { target.getParentFile().mkdirs(); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(target), Charset.forName(encoding)); for (int i = 0; i < files.length; i++) { fileZip(zos, files[i], ""); } zos.close(); } catch (Exception e) { throw new RuntimeException("Failed to process ZIP file.", e); } return target; }  static File createZipFile(File[] files, File target, String encoding); static void unZip(String zipFile, String directory, String encoding); static void extractFile(ZipFile archive, String extractDir); static File getExcelFromFile(File zipFile); final static String ZIP_ENCODING_GBK; final static String ZIP_ENCODING_UTF8; final static int MAX_ZIP_SIZE; final static int MAX_TEMPLATE_SIZE; }