Tabnine Logo
ZipUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
ZipUtil
in
org.jboss.windup.util

Best Java code snippets using org.jboss.windup.util.ZipUtil (Showing top 20 results out of 315)

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;
}
org.jboss.windup.utilZipUtil

Most used methods

  • endsWithZipExtension
  • unzipToFolder
    Unzip the given File to the specified directory.
  • getZipExtensions
  • scanZipFile
  • getEndsWithZipRegularExpression

Popular in Java

  • Creating JSON documents from java classes using gson
  • putExtra (Intent)
  • runOnUiThread (Activity)
  • setRequestProperty (URLConnection)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now