gpt4 book ai didi

org.sonar.api.utils.ZipUtils.zipDir()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 13:30:40 32 4
gpt4 key购买 nike

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

ZipUtils.zipDir介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

private File generateReportFile() {
 try {
  long startTime = System.currentTimeMillis();
  for (ReportPublisherStep publisher : publishers) {
   publisher.publish(writer);
  }
  long stopTime = System.currentTimeMillis();
  LOG.info("Analysis report generated in {}ms, dir size={}", stopTime - startTime, FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(reportDir.toFile())));
  startTime = System.currentTimeMillis();
  File reportZip = temp.newFile("scanner-report", ".zip");
  ZipUtils.zipDir(reportDir.toFile(), reportZip);
  stopTime = System.currentTimeMillis();
  LOG.info("Analysis report compressed in {}ms, zip size={}", stopTime - startTime, FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(reportZip)));
  return reportZip;
 } catch (IOException e) {
  throw new IllegalStateException("Unable to prepare analysis report", e);
 }
}

代码示例来源:origin: SonarSource/sonarqube

private File generateReport() throws IOException {
  File zipDir = tempFolder.newDir();
  File metadataFile = new File(zipDir, "metadata.pb");
  FileUtils.write(metadataFile, "{metadata}");
  File zip = tempFolder.newFile();
  ZipUtils.zipDir(zipDir, zip);
  return zip;
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void zip_directory() throws IOException {
 File foo = FileUtils.toFile(getClass().getResource("/org/sonar/api/utils/ZipUtilsTest/shouldZipDirectory/foo.txt"));
 File dir = foo.getParentFile();
 File zip = temp.newFile();
 ZipUtils.zipDir(dir, zip);
 assertThat(zip).exists().isFile();
 assertThat(zip.length()).isGreaterThan(1L);
 Iterator<? extends ZipEntry> zipEntries = Iterators.forEnumeration(new ZipFile(zip).entries());
 assertThat(zipEntries).hasSize(4);
 File unzipDir = temp.newFolder();
 ZipUtils.unzip(zip, unzipDir);
 assertThat(new File(unzipDir, "bar.txt")).exists().isFile();
 assertThat(new File(unzipDir, "foo.txt")).exists().isFile();
 assertThat(new File(unzipDir, "dir1/hello.properties")).exists().isFile();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_when_jar_is_not_a_plugin() throws IOException {
 // this JAR has a manifest but is not a plugin
 File jarRootDir = temp.newFolder();
 FileUtils.write(new File(jarRootDir, "META-INF/MANIFEST.MF"), "Build-Jdk: 1.6.0_15");
 File jar = temp.newFile();
 ZipUtils.zipDir(jarRootDir, jar);
 expectedException.expect(MessageException.class);
 expectedException.expectMessage("File is not a plugin. Please delete it and restart: " + jar.getAbsolutePath());
 PluginInfo.create(jar);
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

private File prepareReport() {
 try {
  long startTime = System.currentTimeMillis();
  File reportDir = temp.newDir("batch-report");
  BatchReportWriter writer = new BatchReportWriter(reportDir);
  for (ReportPublisher publisher : publishers) {
   publisher.publish(writer);
  }
  long stopTime = System.currentTimeMillis();
  LOG.info("Analysis reports generated in " + (stopTime - startTime) + "ms, dir size=" + FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(reportDir)));
  startTime = System.currentTimeMillis();
  File reportZip = temp.newFile("batch-report", ".zip");
  ZipUtils.zipDir(reportDir, reportZip);
  FileUtils.deleteDirectory(reportDir);
  stopTime = System.currentTimeMillis();
  LOG.info("Analysis reports compressed in " + (stopTime - startTime) + "ms, zip size=" + FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(reportZip)));
  return reportZip;
 } catch (IOException e) {
  throw new IllegalStateException("Unable to prepare batch report", e);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-scanner-engine

private File generateReportFile() {
 try {
  long startTime = System.currentTimeMillis();
  for (ReportPublisherStep publisher : publishers) {
   publisher.publish(writer);
  }
  long stopTime = System.currentTimeMillis();
  LOG.info("Analysis report generated in {}ms, dir size={}", stopTime - startTime, FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(reportDir.toFile())));
  startTime = System.currentTimeMillis();
  File reportZip = temp.newFile("scanner-report", ".zip");
  ZipUtils.zipDir(reportDir.toFile(), reportZip);
  stopTime = System.currentTimeMillis();
  LOG.info("Analysis report compressed in {}ms, zip size={}", stopTime - startTime, FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(reportZip)));
  return reportZip;
 } catch (IOException e) {
  throw new IllegalStateException("Unable to prepare analysis report", e);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

private File generateReportFile() {
 try {
  long startTime = System.currentTimeMillis();
  for (ReportPublisherStep publisher : publishers) {
   publisher.publish(writer);
  }
  long stopTime = System.currentTimeMillis();
  LOG.info("Analysis report generated in {}ms, dir size={}", stopTime - startTime, FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(reportDir)));
  startTime = System.currentTimeMillis();
  File reportZip = temp.newFile("batch-report", ".zip");
  ZipUtils.zipDir(reportDir, reportZip);
  stopTime = System.currentTimeMillis();
  LOG.info("Analysis reports compressed in {}ms, zip size={}", stopTime - startTime, FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(reportZip)));
  return reportZip;
 } catch (IOException e) {
  throw new IllegalStateException("Unable to prepare analysis report", e);
 }
}

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