Package net.md_5.specialsource
Class Jar
java.lang.Object
net.md_5.specialsource.Jar
- All Implemented Interfaces:
Closeable,AutoCloseable
This class wraps one or more
JarFiles enabling quick access to the
jar's main class, as well as the ability to get the InputStream of a
class file, and speedy lookups to see if the jar contains the specified
class.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes all jar files in this JarbooleancontainsClass(String clazz) Check if this jar contains the given class.booleancontainsResource(String name) Check if this jar contains the given resource.Takes the internal name of a class (/).Get the stream for a file in this jar.Get all file names in the jar, (archive order is preserved).org.objectweb.asm.tree.ClassNodeGet theClassNodeobject corresponding to this class.getResource(String name) Get the stream for a file in this jar.static JarRead a new jar instance from the given file.static JarRead a new jar instance from the given list of files.
-
Constructor Details
-
Jar
public Jar()
-
-
Method Details
-
containsClass
Check if this jar contains the given class. Takes the internal name of a class (/).- Parameters:
clazz-- Returns:
-
containsResource
Check if this jar contains the given resource.- Parameters:
name- The name of the resource- Returns:
- true Whether a resource with the given name exists
-
getResource
Get the stream for a file in this jar.- Parameters:
name-- Returns:
- Throws:
IOException
-
getEntry
Get the stream for a file in this jar.- Parameters:
name-- Returns:
- Throws:
IOException
-
getClass
Takes the internal name of a class (/).- Parameters:
clazz-- Returns:
- Throws:
IOException
-
getNode
Get theClassNodeobject corresponding to this class. Takes the internal name of a class (/)- Parameters:
clazz-- Returns:
-
getEntryNames
Get all file names in the jar, (archive order is preserved).- Returns:
-
init
Read a new jar instance from the given file.- Parameters:
file-- Returns:
- Throws:
IOException
-
init
Read a new jar instance from the given list of files.- Parameters:
files-- Returns:
- Throws:
IOException
-
close
Closes all jar files in this Jar- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error has occurred- See Also:
-