gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-15 12:52:40 24 4
gpt4 key购买 nike

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

ZipUtils.doZip介绍

暂无

代码示例

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

private static void doZipDir(File dir, ZipOutputStream out) throws IOException {
 File[] children = dir.listFiles();
 if (children == null) {
  throw new IllegalStateException("Fail to list files of directory " + dir.getAbsolutePath());
 }
 for (File child : children) {
  doZip(child.getName(), child, out);
 }
}

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

private static void doZip(String entryName, File file, ZipOutputStream out) throws IOException {
 if (file.isDirectory()) {
  entryName += "/";
  ZipEntry entry = new ZipEntry(entryName);
  out.putNextEntry(entry);
  out.closeEntry();
  File[] files = file.listFiles();
  // java.io.File#listFiles() returns null if object is a directory (not possible here) or if
  // an I/O error occurs (weird!)
  if (files == null) {
   throw new IllegalStateException("Fail to list files of directory " + file.getAbsolutePath());
  }
  for (File f : files) {
   doZip(entryName + f.getName(), f, out);
  }
 } else {
  try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
   doZip(entryName, in, out);
  }
 }
}

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

private static void zip(File file, ZipOutputStream out) throws IOException {
 for (File child : file.listFiles()) {
  String name = child.getName();
  doZip(name, child, out);
 }
}

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

private static void doZipDir(File dir, ZipOutputStream out) throws IOException {
 File[] children = dir.listFiles();
 if (children == null) {
  throw new IllegalStateException("Fail to list files of directory " + dir.getAbsolutePath());
 }
 for (File child : children) {
  doZip(child.getName(), child, out);
 }
}

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

private static void doZip(String entryName, File file, ZipOutputStream out) throws IOException {
 if (file.isDirectory()) {
  entryName += '/';
  ZipEntry entry = new ZipEntry(entryName);
  out.putNextEntry(entry);
  out.closeEntry();
  File[] files = file.listFiles();
  for (int i = 0, len = files.length; i < len; i++) {
   doZip(entryName + files[i].getName(), files[i], out);
  }
 } else {
  InputStream in = null;
  try {
   in = new BufferedInputStream(new FileInputStream(file));
   doZip(entryName, in, out);
  } finally {
   IOUtils.closeQuietly(in);
  }
 }
}

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

private static void doZip(String entryName, File file, ZipOutputStream out) throws IOException {
 if (file.isDirectory()) {
  entryName += "/";
  ZipEntry entry = new ZipEntry(entryName);
  out.putNextEntry(entry);
  out.closeEntry();
  File[] files = file.listFiles();
  // java.io.File#listFiles() returns null if object is a directory (not possible here) or if
  // an I/O error occurs (weird!)
  if (files == null) {
   throw new IllegalStateException("Fail to list files of directory " + file.getAbsolutePath());
  }
  for (File f : files) {
   doZip(entryName + f.getName(), f, out);
  }
 } else {
  try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
   doZip(entryName, in, out);
  }
 }
}

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