public class JarContentsManager extends Object
Constructor and Description |
---|
JarContentsManager() |
Modifier and Type | Method and Description |
---|---|
boolean |
containsPath(File jar,
String filePath)
Checks if a jar file contains a path specified (case sensitive).
|
void |
copyFilesFromJarTrimmingBasePath(File jar,
String jarDirectoryToCopyFrom,
File outputDirectory,
String... wildcardPathExclusions)
Copies files from the jar file to the output directory.
|
void |
copyIncludedFilesFromJarTrimmingBasePath(File jar,
String jarDirectoryToCopyFrom,
File outputDirectory,
String... wildcardPathInclusions)
Copies files matching the inclusion filters from the jar file to the
output directory.
|
List<String> |
findFiles(File jar,
String baseDirectoryName,
String fileName)
Finds all files (not directories) in the jar with the name specified and
in the directory specified.
|
byte[] |
getFileContents(File jar,
String filePath)
Tries to find a file by its path (case sensitive) in jar file.
|
public boolean containsPath(File jar, String filePath)
jar
- jar file to look for file in, not null
filePath
- file path relative to jar root, not null
true
if path is contained in the jar, false
otherwiseIllegalArgumentException
- if jar file specified is not a file or does not existNullPointerException
- if any of the arguments is nullUncheckedIOException
- if IOException
occurs during file search, for
instance, when jar file specified is not a jar filepublic byte[] getFileContents(File jar, String filePath)
null
otherwise.jar
- jar file to look for file in, not null
filePath
- file path relative to jar root, not null
null
if not foundIllegalArgumentException
- if jar file specified is not a file or does not existNullPointerException
- if any of the arguments is nullUncheckedIOException
- if IOException
occurs during file retrieval, for
instance, when jar file specified is not a jar filepublic List<String> findFiles(File jar, String baseDirectoryName, String fileName)
jar
- jar file to look for file in, not null
baseDirectoryName
- the directory to search in the jar, not null
fileName
- a string that should required files' paths end with, not
null
IllegalArgumentException
- if jar file specified is not a file or does not existNullPointerException
- if any of the arguments is nullUncheckedIOException
- if IOException
occurs during jar file searchpublic void copyFilesFromJarTrimmingBasePath(File jar, String jarDirectoryToCopyFrom, File outputDirectory, String... wildcardPathExclusions)
jar
- jar file to look for files in, not null
jarDirectoryToCopyFrom
- a path relative to jar root, only files from this path will be
copied, can be null
, which is treated as a root of the
jar. Files will be copied relative to this path (i.e. only
path part after this path is preserved in output directory)outputDirectory
- the directory to copy files to, not null
wildcardPathExclusions
- wildcard exclusions that are used to check each path against
before copyingIllegalArgumentException
- if jar file specified is not a file or does not exist or if
output directory is not a directory or does not existNullPointerException
- if jar file or output directory is null
UncheckedIOException
- if IOException
occurs during the operation, for
instance, when jar file specified is not a jar filepublic void copyIncludedFilesFromJarTrimmingBasePath(File jar, String jarDirectoryToCopyFrom, File outputDirectory, String... wildcardPathInclusions)
jar
- jar file to look for files in, not null
jarDirectoryToCopyFrom
- a path relative to jar root, only files from this path will be
copied, can be null
, which is treated as a root of the
jar. Files will be copied relative to this path (i.e. only
path part after this path is preserved in output directory)outputDirectory
- the directory to copy files to, not null
wildcardPathInclusions
- wildcard inclusions that are used to check each path against
before copyingIllegalArgumentException
- if jar file specified is not a file or does not exist or if
output directory is not a directory or does not existNullPointerException
- if jar file or output directory is null
UncheckedIOException
- if IOException
occurs during the operation, for
instance, when jar file specified is not a jar fileCopyright © 2020. All rights reserved.