Class JarUtil

java.lang.Object
proguard.examples.JarUtil

public class JarUtil extends Object
This utility class provides methods to read and write the classes in jars.
  • Constructor Details

    • JarUtil

      public JarUtil()
  • Method Details

    • readJar

      public static ClassPool readJar(String jarFileName, boolean isLibrary) throws IOException
      Reads the classes from the specified jar file and returns them as a class pool.
      Parameters:
      jarFileName - the name of the jar file or jmod file.
      isLibrary - specifies whether classes should be represented as ProgramClass instances (for processing) or LibraryClass instances (more compact).
      Returns:
      a new class pool with the read classes.
      Throws:
      IOException
    • readJar

      public static ClassPool readJar(String jarFileName, String classNameFilter, boolean isLibrary) throws IOException
      Reads the classes from the specified jar file and returns them as a class pool.
      Parameters:
      jarFileName - the name of the jar file or jmod file.
      isLibrary - specifies whether classes should be represented as ProgramClass instances (for processing) or LibraryClass instances (more compact).
      Returns:
      a new class pool with the read classes.
      Throws:
      IOException
    • writeJar

      public static void writeJar(ClassPool programClassPool, String outputJarFileName) throws IOException
      Writes the classes from the given class pool to a specified jar.
      Parameters:
      programClassPool - the classes to write.
      outputJarFileName - the name of the output jar file.
      Throws:
      IOException