gpt4 book ai didi

org.jboss.windup.util.ZipUtil.scanZipFile()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 11:43:31 27 4
gpt4 key购买 nike

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

ZipUtil.scanZipFile介绍

暂无

代码示例

代码示例来源:origin: org.jboss.windup.utils/windup-utils

public static List<String> scanZipFile(Path zipFilePath, boolean relativeOnly)
{
  try
  {
    try (final InputStream is = new FileInputStream(zipFilePath.toFile()))
    {
      return scanZipFile(zipFilePath.normalize().toString(), is, relativeOnly);
    }
  }
  catch (IOException e)
  {
    System.err.println("Could not read file: " + zipFilePath + " due to: " + e.getMessage());
    return Collections.emptyList();
  }
}

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

public static List<String> scanZipFile(Path zipFilePath, boolean relativeOnly)
{
  try
  {
    try (final InputStream is = new FileInputStream(zipFilePath.toFile()))
    {
      return scanZipFile(zipFilePath.normalize().toString(), is, relativeOnly);
    }
  }
  catch (IOException e)
  {
    System.err.println("Could not read file: " + zipFilePath + " due to: " + e.getMessage());
    return Collections.emptyList();
  }
}

代码示例来源:origin: org.jboss.windup.utils/windup-utils

public static List<String> scanZipFile(String parentPath, InputStream is, boolean relativeOnly)
{
  try
  {
    ZipInputStream zis = new ZipInputStream(is);
    ZipEntry entry;
    List<String> results = new ArrayList<>();
    while ((entry = zis.getNextEntry()) != null)
    {
      String fullPath = parentPath + "/" + entry.getName();
      results.add(relativeOnly ? entry.getName() : fullPath);
      if (!entry.isDirectory() && ZipUtil.endsWithZipExtension(entry.getName()))
      {
        results.addAll(scanZipFile(fullPath, zis, relativeOnly));
      }
    }
    return results;
  }
  catch (IOException e)
  {
    System.err.println("Could not read file: " + parentPath + " due to: " + e.getMessage());
    return Collections.emptyList();
  }
}

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

public static List<String> scanZipFile(String parentPath, InputStream is, boolean relativeOnly)
{
  try
  {
    ZipInputStream zis = new ZipInputStream(is);
    ZipEntry entry;
    List<String> results = new ArrayList<>();
    while ((entry = zis.getNextEntry()) != null)
    {
      String fullPath = parentPath + "/" + entry.getName();
      results.add(relativeOnly ? entry.getName() : fullPath);
      if (!entry.isDirectory() && ZipUtil.endsWithZipExtension(entry.getName()))
      {
        results.addAll(scanZipFile(fullPath, zis, relativeOnly));
      }
    }
    return results;
  }
  catch (IOException e)
  {
    System.err.println("Could not read file: " + parentPath + " due to: " + e.getMessage());
    return Collections.emptyList();
  }
}

代码示例来源:origin: org.jboss.windup/windup-bootstrap

private static List<String> findPaths(Path path, boolean relativeOnly)
{
  List<String> results = new ArrayList<>();
  results.add(path.normalize().toAbsolutePath().toString());
  if (Files.isDirectory(path))
  {
    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path))
    {
      for (Path child : directoryStream)
      {
        results.addAll(findPaths(child, relativeOnly));
      }
    }
    catch (IOException e)
    {
      System.err.println("Could not read file: " + path + " due to: " + e.getMessage());
    }
  }
  else if (Files.isRegularFile(path) && ZipUtil.endsWithZipExtension(path.toString()))
  {
    results.addAll(ZipUtil.scanZipFile(path, relativeOnly));
  }
  return results;
}

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

private static List<String> findPaths(Path path, boolean relativeOnly)
{
  List<String> results = new ArrayList<>();
  results.add(path.normalize().toAbsolutePath().toString());
  if (Files.isDirectory(path))
  {
    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path))
    {
      for (Path child : directoryStream)
      {
        results.addAll(findPaths(child, relativeOnly));
      }
    }
    catch (IOException e)
    {
      System.err.println("Could not read file: " + path + " due to: " + e.getMessage());
    }
  }
  else if (Files.isRegularFile(path) && ZipUtil.endsWithZipExtension(path.toString()))
  {
    results.addAll(ZipUtil.scanZipFile(path, relativeOnly));
  }
  return results;
}

代码示例来源:origin: org.jboss.windup.web.addons/windup-web-support-impl

private static List<String> findPaths(Path path, boolean relativeOnly)
  {
    List<String> results = new ArrayList<>();
    results.add(path.normalize().toAbsolutePath().toString());

    if (Files.isDirectory(path))
    {
      try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path))
      {
        for (Path child : directoryStream)
        {
          results.addAll(findPaths(child, relativeOnly));
        }
      }
      catch (IOException e)
      {
        Logger.getLogger(PackageDiscoveryServiceImpl.class).warn("Could not read file: " + path + " due to: " + e.getMessage());
      }
    }
    else if (Files.isRegularFile(path) && ZipUtil.endsWithZipExtension(path.toString()))
    {
      results.addAll(ZipUtil.scanZipFile(path, relativeOnly));
    }

    return results;
  }
}

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