gpt4 book ai didi

org.rhq.core.util.ZipUtil.unzipFile()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 09:49:31 25 4
gpt4 key购买 nike

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

ZipUtil.unzipFile介绍

[英]Unzips the content of the given zip file to the specified directory.
[中]将给定zip文件的内容解压缩到指定目录。

代码示例

代码示例来源:origin: rhq-project/rhq

/**
 * Unzips the content of the given zip file to the specified directory.
 *
 * @param  zipFile the zip file to unzip
 * @param  destDir root directory where the zip files will be extracted
 *
 * @throws IOException if any errors occur during the reading or writing
 */
public static void unzipFile(File zipFile, File destDir) throws IOException {
  destDir.mkdirs();
  InputStream is = new BufferedInputStream(new FileInputStream(zipFile));
  ZipUtil.unzipFile(is, destDir);
}

代码示例来源:origin: org.rhq/rhq-cassandra-ccm-core

public void unzipDistro() throws DeploymentException {
  InputStream inputStream = getClass().getResourceAsStream("/cassandra.zip");
  File deployDir = new File(deploymentOptions.getBasedir());
  deployDir.mkdir();
  try {
    log.info("Unzipping storage node to " + deployDir);
    ZipUtil.unzipFile(inputStream, deployDir);
  } catch (IOException e) {
    log.error("An error occurred while unzipping the storage zip file", e);
    throw new DeploymentException("An error occurred while unzipping the storage zip file", e);
  }
}

代码示例来源:origin: org.rhq/rhq-enterprise-server

dir.mkdir();
ZipUtil.unzipFile(filesZip, dir);
for (File file : dir.listFiles()) {
  JPADriftFile driftFile = new JPADriftFile(file.getName());

代码示例来源:origin: org.jboss.on/jopr-tomcat-plugin

/**
 * Creates a new package described by the specified details. The destination of the content in the provided input
 * stream will be determined by the package name.
 *
 * @param  contentFile  the file to write the content to
 * @param  content  content to be written for the package. NOTE this Stream will be closed by this method.
 * @param  unzip    if <code>true</code>, the content stream will be treated like a ZIP file and be unzipped as
 *                  it is written, using the package name as the base directory; if <code>false</code> the
 *                  content will be written to directly to a file using the package name as the file name
 */
public void createContent(File destination, File content, boolean unzip) {
  try {
    if (unzip) {
      ZipUtil.unzipFile(content, destination);
      String sha = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(content);
      writeSHAToManifest(destination, sha);
    } else {
      InputStream contentStream = new BufferedInputStream(new FileInputStream(content));
      FileUtil.writeFile(contentStream, destination);
    }
  } catch (IOException e) {
    throw new RuntimeException("Error creating artifact for contentFile: " + destination, e);
  }
}

代码示例来源:origin: org.rhq/rhq-core-plugin-api

/**
 * Creates a new package described by the specified details. The destination of the content in the provided input
 * stream will be determined by the package name.
 *
 * @param  details  describes the package being created
 * @param  content  content to be written for the package. NOTE this Stream will be closed by this method.
 * @param  unzip    if <code>true</code>, the content stream will be treated like a ZIP file and be unzipped as
 *                  it is written, using the package name as the base directory; if <code>false</code> the
 * @param createBackup If <code>true</code>, the original file will be backed up to file.bak
 */
public void createContent(PackageDetails details, File content, boolean unzip) {
  File destination = getPath(details);
  try {
    if (unzip) {
      ZipUtil.unzipFile(content, destination);
    } else {
      FileUtil.copyFile(content, destination);
    }
    details.setFileName(destination.getPath());
  } catch (IOException e) {
    throw new RuntimeException("Error creating artifact from details: " + destination, e);
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com