java.lang.Object | |
↳ | com.pdftron.pdf.JarResourceExtractor |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
JarResourceExtractor() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static Path |
createTempDirWithPrefix(String prefix)
Creates a temporary directory using the specified prefix.
| ||||||||||
static void |
extractJarResources(Path jarPath, Path destinationDir)
Extracts resources from a JAR file to a specified directory using a reference to the JAR's Path.
| ||||||||||
static Path |
extractJarResourcesByClassName(String markerClassName)
Extracts resources from a JAR file to a newly created temporary directory using
the package name of a marker class within the JAR.
| ||||||||||
static Path |
resolveJarPathFromClass(Class<?> markerClass)
Returns the Path to the JAR file from which the given class was loaded.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Creates a temporary directory using the specified prefix. If the system property 'com.pdftron.systemloadtmpdir' is set, the directory will be created there; otherwise, it defaults to the system temp directory.
Important: The caller is responsible for deleting this directory and its contents when it is no longer needed to avoid resource leaks and clutter in the filesystem. This method does not perform any automatic cleanup.
prefix | the prefix string to be used in generating the directory's name; must not be null or empty |
---|
IOException | if the directory could not be created |
---|---|
IllegalArgumentException | if prefix is empty |
NullPointerException | if prefix is null
|
Extracts resources from a JAR file to a specified directory using a reference to the JAR's Path.
jarPath | the path to the JAR file to extract |
---|---|
destinationDir | the directory to extract the contents of the JAR file into |
IOException | if an I/O error occurs or a zip-slip attempt is detected |
---|---|
IllegalArgumentException | if the jarPath is invalid (not a file, doesn't exist, or doesn't end with .jar) |
Extracts resources from a JAR file to a newly created temporary directory using the package name of a marker class within the JAR.
The method attempts to locate the JAR file from which the specified marker class was loaded, creates a temporary directory with a prefix based on the marker class's package name, and extracts all resources from the JAR (except directories and META-INF entries) into this directory.
All files and directories extracted into the temporary directory are
registered for automatic deletion on JVM exit using deleteOnExit()
.
Note: While this helps clean up resources, it only guarantees deletion when the JVM shuts down normally. If the JVM is abruptly terminated, the files may remain on disk.
The caller does not need to explicitly delete the temporary directory, but should be aware that the directory may persist during the JVM's lifetime.
markerClassName | the fully-qualified name of a class inside the JAR to be extracted; must not be null or empty |
---|
NullPointerException | if markerClassName is null |
---|---|
IllegalArgumentException | if markerClassName is empty
|
Returns the Path to the JAR file from which the given class was loaded. Returns null if the class was not loaded from a JAR.
markerClass | a class inside the JAR you want to resolve. |
---|