org.zeroturnaround.zip.ZipUtil.unpack()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中org.zeroturnaround.zip.ZipUtil.unpack()方法的一些代码示例,展示了ZipUtil.unpack()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil.unpack()方法的具体详情如下:
包路径:org.zeroturnaround.zip.ZipUtil
类名称:ZipUtil
方法名:unpack

ZipUtil.unpack介绍

[英]Unpacks a ZIP file to the given directory.

The output directory must not be a file.
[中]将ZIP文件解压缩到给定目录。
输出目录不能是文件。

代码示例

代码示例来源:origin: zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP file to the given directory.
  3. * <p>
  4. * The output directory must not be a file.
  5. *
  6. * @param zip
  7. * input ZIP file.
  8. * @param outputDir
  9. * output directory (created automatically if not found).
  10. */
  11. public static void unpack(File zip, final File outputDir) {
  12. unpack(zip, outputDir, IdentityNameMapper.INSTANCE);
  13. }

代码示例来源:origin: zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP stream to the given directory.
  3. * <p>
  4. * The output directory must not be a file.
  5. *
  6. * @param is
  7. * inputstream for ZIP file.
  8. * @param outputDir
  9. * output directory (created automatically if not found).
  10. */
  11. public static void unpack(InputStream is, File outputDir) {
  12. unpack(is, outputDir, IdentityNameMapper.INSTANCE, null);
  13. }

代码示例来源:origin: zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP stream to the given directory.
  3. * <p>
  4. * The output directory must not be a file.
  5. *
  6. * @param is
  7. * inputstream for ZIP file.
  8. * @param outputDir
  9. * output directory (created automatically if not found).
  10. * @param mapper
  11. * call-back for renaming the entries.
  12. */
  13. public static void unpack(InputStream is, File outputDir, NameMapper mapper) {
  14. unpack(is, outputDir, mapper, null);
  15. }

代码示例来源:origin: zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP stream to the given directory.
  3. * <p>
  4. * The output directory must not be a file.
  5. *
  6. * @param is
  7. * inputstream for ZIP file.
  8. * @param outputDir
  9. * output directory (created automatically if not found).
  10. * @param charset
  11. * charset used to process the zip stream
  12. */
  13. public static void unpack(InputStream is, File outputDir, Charset charset) {
  14. unpack(is, outputDir, IdentityNameMapper.INSTANCE, charset);
  15. }

代码示例来源:origin: zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP file to the given directory using a specific Charset
  3. * for the input file.
  4. *
  5. * <p>
  6. * The output directory must not be a file.
  7. *
  8. * @param zip
  9. * input ZIP file.
  10. * @param outputDir
  11. * output directory (created automatically if not found).
  12. *
  13. * @param charset
  14. * charset used to unpack the zip file
  15. */
  16. public static void unpack(File zip, final File outputDir, Charset charset) {
  17. unpack(zip, outputDir, IdentityNameMapper.INSTANCE, charset);
  18. }

代码示例来源:origin: jphp-group/jphp

  1. @Signature
  2. public void unpack(File outputDir, String charset, @Nullable final Invoker callback) throws FileNotFoundException {
  3. if (!zipFile.isFile()) {
  4. throw new FileNotFoundException(zipFile.getPath() + " not found");
  5. }
  6. NameMapper mapper = invokerToNameMapper(callback);
  7. if (charset == null || charset.isEmpty()) {
  8. ZipUtil.unpack(zipFile, outputDir, mapper);
  9. } else {
  10. ZipUtil.unpack(zipFile, outputDir, Charset.forName(charset));
  11. }
  12. }

代码示例来源:origin: libgdx/packr

  1. ZipUtil.unpack(jar, jarDir);
  2. } else {

代码示例来源:origin: zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP file to its own location.
  3. * <p>
  4. * The ZIP file will be first renamed (using a temporary name). After the
  5. * extraction it will be deleted.
  6. *
  7. * @param zip
  8. * input ZIP file as well as the target directory.
  9. *
  10. * @see #unpack(File, File)
  11. */
  12. public static void explode(File zip) {
  13. try {
  14. // Find a new unique name is the same directory
  15. File tempFile = FileUtils.getTempFileFor(zip);
  16. // Rename the archive
  17. FileUtils.moveFile(zip, tempFile);
  18. // Unpack it
  19. unpack(tempFile, zip);
  20. // Delete the archive
  21. if (!tempFile.delete()) {
  22. throw new IOException("Unable to delete file: " + tempFile);
  23. }
  24. }
  25. catch (IOException e) {
  26. throw ZipExceptionUtil.rethrow(e);
  27. }
  28. }

代码示例来源:origin: libgdx/packr

  1. PackrFileUtils.copyDirectory(jdkFile, tmp);
  2. } else {
  3. ZipUtil.unpack(jdkFile, tmp);

代码示例来源:origin: libgdx/packr

  1. System.out.println(" # Unpacking '" + file.getPath() + "' ...");
  2. ZipUtil.unpack(file, fileNoExt);

代码示例来源:origin: org.zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP file to the given directory.
  3. * <p>
  4. * The output directory must not be a file.
  5. *
  6. * @param zip
  7. * input ZIP file.
  8. * @param outputDir
  9. * output directory (created automatically if not found).
  10. */
  11. public static void unpack(File zip, final File outputDir) {
  12. unpack(zip, outputDir, IdentityNameMapper.INSTANCE);
  13. }

代码示例来源:origin: hs-web/hsweb-expands

  1. public void unpack(File to) throws IOException {
  2. ZipUtil.unpack(zipFile, to);
  3. }

代码示例来源:origin: org.zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP stream to the given directory.
  3. * <p>
  4. * The output directory must not be a file.
  5. *
  6. * @param is
  7. * inputstream for ZIP file.
  8. * @param outputDir
  9. * output directory (created automatically if not found).
  10. */
  11. public static void unpack(InputStream is, File outputDir) {
  12. unpack(is, outputDir, IdentityNameMapper.INSTANCE, null);
  13. }

代码示例来源:origin: org.hswebframework/hsweb-expands-compress

  1. public void unpack(File to) throws IOException {
  2. ZipUtil.unpack(zipFile, to);
  3. }

代码示例来源:origin: org.zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP stream to the given directory.
  3. * <p>
  4. * The output directory must not be a file.
  5. *
  6. * @param is
  7. * inputstream for ZIP file.
  8. * @param outputDir
  9. * output directory (created automatically if not found).
  10. * @param charset
  11. * charset used to process the zip stream
  12. */
  13. public static void unpack(InputStream is, File outputDir, Charset charset) {
  14. unpack(is, outputDir, IdentityNameMapper.INSTANCE, charset);
  15. }

代码示例来源:origin: org.zeroturnaround/zt-zip

  1. /**
  2. * Unpacks a ZIP stream to the given directory.
  3. * <p>
  4. * The output directory must not be a file.
  5. *
  6. * @param is
  7. * inputstream for ZIP file.
  8. * @param outputDir
  9. * output directory (created automatically if not found).
  10. * @param mapper
  11. * call-back for renaming the entries.
  12. */
  13. public static void unpack(InputStream is, File outputDir, NameMapper mapper) {
  14. unpack(is, outputDir, mapper, null);
  15. }

代码示例来源:origin: molgenis/molgenis

  1. public static void unzip(InputStream is, File outputDir) {
  2. try {
  3. ZipUtil.unpack(is, outputDir);
  4. } catch (Exception ex) {
  5. throw new UnzipException(ex);
  6. }
  7. }

代码示例来源:origin: PlayPen/playpen-core

  1. @Override
  2. public boolean runStep(P3Package p3, PackageContext ctx, JSONObject config) {
  3. log.info("Expanding package to " + ctx.getDestination().getPath());
  4. try {
  5. ZipUtil.unpack(new File(p3.getLocalPath()), ctx.getDestination());
  6. }
  7. catch(ZipException e) {
  8. log.error("Unable to expand package", e);
  9. return false;
  10. }
  11. return true;
  12. }
  13. }

代码示例来源:origin: alexcojocaru/elasticsearch-maven-plugin

  1. private File unpackToElasticsearchDirectory(File artifact, InstanceConfiguration config)
  2. throws IOException
  3. {
  4. File unpackDirectory = getUnpackDirectory();
  5. ZipUtil.unpack(artifact, unpackDirectory);
  6. File baseDir = new File(config.getBaseDir());
  7. moveToElasticsearchDirectory(unpackDirectory, baseDir);
  8. return unpackDirectory;
  9. }

代码示例来源:origin: molgenis/molgenis

  1. /**
  2. * Unzips a zipfile into the directory it resides in.
  3. *
  4. * @param file the zipfile to unzip
  5. * @param nameMapper the {@link NameMapper} to use when unzipping
  6. * @return List of Files that got extracted
  7. * @throws UnzipException if something went wrong
  8. */
  9. private static List<File> unzip(File file, NameMapper nameMapper) {
  10. try {
  11. File parentFile = file.getParentFile();
  12. TrackingNameMapper trackingNameMapper = new TrackingNameMapper(parentFile, nameMapper);
  13. ZipUtil.unpack(file, parentFile, trackingNameMapper);
  14. return trackingNameMapper.getFiles();
  15. } catch (Exception ex) {
  16. throw new UnzipException(ex);
  17. }
  18. }

相关文章