gpt4 book ai didi

org.jboss.windup.util.ZipUtil类的使用及代码示例

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

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

ZipUtil介绍

暂无

代码示例

代码示例来源: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

/**
 * Unzip a classpath resource using the given {@link Class} as the resource root path.
 */
public static void unzipFromClassResource(Class<?> clazz, String resourcePath, File extractToPath) throws IOException
{
  File inputFile = File.createTempFile("windup-resource-to-unzip-", ".zip");
  try
  {
    try (final InputStream stream = clazz.getResourceAsStream(resourcePath))
    {
      FileUtils.copyInputStreamToFile(stream, inputFile);
    }
    extractToPath.mkdirs();
    ZipUtil.unzipToFolder(inputFile, extractToPath);
  }
  finally
  {
    inputFile.delete();
  }
}

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

public static boolean endsWithZipExtension(String path)
{
  for (String extension : getZipExtensions())
  {
    if (StringUtils.endsWith(path, "." + extension))
    {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-api

projectModel.setDescription("Not available");
if(ZipUtil.endsWithZipExtension(archiveModel.getArchiveName()))
  for (String extension : ZipUtil.getZipExtensions())

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

private static boolean isJavaArchive(Path path)
  {
    return ZipUtil.endsWithZipExtension(path.toString());
  }
}

代码示例来源: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.rules.apps/rules-java

@Override
public Configuration getConfiguration(GraphContext context)
{
  return ConfigurationBuilder.begin()
  .addRule()
  .when(Query.fromType(FileModel.class)
    .withProperty(FileModel.IS_DIRECTORY, true)
  )
  .perform(new RecurseDirectoryAndAddFiles()
  )
  .addRule()
  .when(Query.fromType(FileModel.class)
    .withProperty(FileModel.IS_DIRECTORY, false)
    .withProperty(FileModel.FILE_PATH,
      QueryPropertyComparisonType.REGEX,
      ZipUtil.getEndsWithZipRegularExpression())
  )
  .perform(
    new AddArchiveReferenceInformation()
  );
}
// @formatter:on

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

projectModel.setDescription("Not available");
if(ZipUtil.endsWithZipExtension(archiveModel.getArchiveName()))
  for (String extension : ZipUtil.getZipExtensions())

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

private static boolean isJavaArchive(Path path)
  {
    return ZipUtil.endsWithZipExtension(path.toString());
  }
}

代码示例来源: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: org.jboss.windup.rules.apps/windup-rules-java-api

@Override
public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext)
{
  return ConfigurationBuilder.begin()
  .addRule()
  .when(Query.fromType(WindupConfigurationModel.class)
      .piped((GraphRewrite event, GraphTraversal<?, Vertex> pipeline) -> {
        pipeline.out(WindupConfigurationModel.INPUT_PATH);
        pipeline.has(FileModel.IS_DIRECTORY, true);
      })
  )
  .perform(new RecurseDirectoryAndAddFiles())
  .addRule()
  .when(Query.fromType(FileModel.class)
    .withProperty(FileModel.IS_DIRECTORY, false)
    .withProperty(FileModel.FILE_PATH, QueryPropertyComparisonType.REGEX, ZipUtil.getEndsWithZipRegularExpression())
  )
  .perform(
    new AddArchiveReferenceInformation()
  );
}
// @formatter:on

代码示例来源: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.rules.apps/rules-java

if (subFile.isFile() && ZipUtil.endsWithZipExtension(subFileModel.getFilePath()))

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

/**
 * Unzip a classpath resource using the given {@link Class} as the resource root path.
 */
public static void unzipFromClassResource(Class<?> clazz, String resourcePath, File extractToPath) throws IOException
{
  File inputFile = File.createTempFile("windup-resource-to-unzip-", ".zip");
  try
  {
    try (final InputStream stream = clazz.getResourceAsStream(resourcePath))
    {
      FileUtils.copyInputStreamToFile(stream, inputFile);
    }
    extractToPath.mkdirs();
    ZipUtil.unzipToFolder(inputFile, extractToPath);
  }
  finally
  {
    inputFile.delete();
  }
}

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

public static boolean endsWithZipExtension(String path)
{
  for (String extension : getZipExtensions())
  {
    if (StringUtils.endsWith(path, "." + extension))
    {
      return true;
    }
  }
  return false;
}

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

@Override
public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext)
{
  return ConfigurationBuilder.begin()
  .addRule()
  .when(Query.fromType(WindupConfigurationModel.class)
      .piped((GraphRewrite event, GraphTraversal<?, Vertex> pipeline) -> {
        pipeline.out(WindupConfigurationModel.INPUT_PATH);
        pipeline.has(FileModel.IS_DIRECTORY, true);
      })
  )
  .perform(new RecurseDirectoryAndAddFiles())
  .addRule()
  .when(Query.fromType(FileModel.class)
    .withProperty(FileModel.IS_DIRECTORY, false)
    .withProperty(FileModel.FILE_PATH, QueryPropertyComparisonType.REGEX, ZipUtil.getEndsWithZipRegularExpression())
  )
  .perform(
    new AddArchiveReferenceInformation()
  );
}
// @formatter:on

代码示例来源: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

continue;
if (subArchivesOnly && !ZipUtil.endsWithZipExtension(subFile.getAbsolutePath()))
  continue;
  event.getGraphContext().commit();
if (subFile.isFile() && ZipUtil.endsWithZipExtension(subFileModel.getFilePath()))

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

public void extractArtifact(Coordinate artifactCoords, File targetDir) throws IOException, DependencyException
{
  final DependencyQueryBuilder query = DependencyQueryBuilder.create(artifactCoords);
  Dependency dependency = depsResolver.resolveArtifact(query);
  FileResource<?> artifact = dependency.getArtifact();
  ZipUtil.unzipToFolder(new File(artifact.getFullyQualifiedName()), targetDir);
}

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

public static boolean endsWithZipExtension(String path)
{
  for (String extension : getZipExtensions())
  {
    if (StringUtils.endsWith(path, "." + extension))
    {
      return true;
    }
  }
  return false;
}

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