Package org.beangle.commons.archiver.zip

Examples of org.beangle.commons.archiver.zip.ZipOutputStream


  // 文件压缩
  public static File zip(List<String> fileNames, String zipPath, String encoding) {
    try {
      FileOutputStream f = new FileOutputStream(zipPath);
      ZipOutputStream out = new ZipOutputStream(new DataOutputStream(f));
      // FIXME
      out.setEncoding(encoding);
      for (int i = 0; i < fileNames.size(); i++) {
        String fileName = fileNames.get(i);
        DataInputStream in = new DataInputStream(new FileInputStream(fileName));
        String entryName = StringUtils.substringAfterLast(fileName, File.separator);
        out.putNextEntry(new ZipEntry(entryName));
        int c;
        while ((c = in.read()) != -1) {
          out.write(c);
        }
        in.close();
      }
      out.close();
      return new File(zipPath);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

TOP

Related Classes of org.beangle.commons.archiver.zip.ZipOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.