public class Resource extends Object
URL image = Resource.getURL("/images/bidulle.png");Created: 5 août 2003
Modifier | Constructor and Description |
---|---|
protected |
Resource() |
Modifier and Type | Method and Description |
---|---|
static boolean |
containsDirectDirectory(URL url,
String directory)
Test if an url contains the given directory with no recurse seeking.
|
protected static List<URL> |
doFindMatchingFileSystemResources(URL rootDirResource,
String subPattern)
Find all resources in the file system that match the given location pattern
via the Java style matcher.
|
protected static List<URL> |
doFindPathMatchingJarResources(URL rootDirResource,
String subPattern)
Find all resources in jar files that match the given location pattern
via the Java Regex style Matcher.
|
protected static void |
doRetrieveMatchingFiles(String fullPattern,
File dir,
List<URL> result)
Recursively retrieve files that match the given pattern,
adding them to the given result list.
|
static URL[] |
getClassPathURLsFromJarManifest(URL jarURL) |
static ImageIcon |
getIcon(String name)
Retourne l'icone demandee.
|
protected static List<URL> |
getPatternRessources(String pattern,
ClassLoader classLoader)
Obtain some resources from a pattern using a specific class loader to
seel resources.
|
static List<URL> |
getResources(String pattern)
Find pattern resouces in
ClassLoader.getSystemClassLoader() . |
static List<URL> |
getResources(String pattern,
ClassLoader classLoader)
Find pattern resouces in classloader.
|
static URL |
getURL(String name)
Recherche la ressource nom.
|
static URL |
getURLOrNull(String name)
Recherche la ressource nom.
|
static List<URL> |
getURLs(String pattern)
Retourner la liste des fichiers du classLoader.
|
static List<URL> |
getURLs(String pattern,
URL... arrayURL)
Retourner la liste des fichiers du classLoader.
|
static List<URL> |
getURLs(String pattern,
URLClassLoader urlClassLoader)
Retourner la liste des fichiers du classLoader.
|
static List<URL> |
getURLsFromDirectory(File repository,
String pattern)
Retourne la liste des fichiers correspondant au pattern donne, aucun
ordre ne doit être supposé sur les fichiers.
|
static List<URL> |
getURLsFromJar(File jarfile,
String pattern) |
static List<URL> |
getURLsFromZip(File zipFile,
String pattern) |
static boolean |
isJar(String name)
Verifie si le fichier est un fichier jar.
|
static boolean |
isJarUrl(URL url)
Test if an url detnoe a jar file.
|
protected static boolean |
isPattern(String str)
Return true if
str is a pattern (contains * or ?). |
static boolean |
isZip(String name)
Verifie si le fichier est un fichier zip
|
protected static List<URL> |
retrieveMatchingFiles(File rootDir,
String pattern)
Retrieve files that match the given path pattern,
checking the given directory and its subdirectories.
|
protected static List<URL> |
walkThroughClassLoaderAndGetURLs(String pattern) |
public static URL getURL(String name)
name
- nom de la ressourceResourceNotFoundException
- si la resource n'a pas ete trouveepublic static URL getURLOrNull(String name)
name
- le nom de la ressourcepublic static ImageIcon getIcon(String name)
name
- le nom de l'iconepublic static List<URL> getURLs(String pattern)
ClassLoader.getSystemClassLoader()
.pattern
- le nom du fichier a extraire du fichier compressé ou
du repertoire doit correspondre au pattern (repertoire + nom
compris).public static List<URL> getURLs(String pattern, URLClassLoader urlClassLoader)
urlClassLoader
- classloader to use (if null, use ClassLoader.getSystemClassLoader()
pattern
- le nom du fichier a extraire du fichier compressé ou
du repertoire doit correspondre au pattern (repertoire + nom
compris).protected static List<URL> walkThroughClassLoaderAndGetURLs(String pattern)
public static List<URL> getURLs(String pattern, URL... arrayURL)
arrayURL
- les urls ou chercherpattern
- le nom du fichier a extraire du fichier compressé ou
dur epertoire doit correspondre au pattern (repertoire + nom
compris).public static URL[] getClassPathURLsFromJarManifest(URL jarURL) throws IOException
IOException
public static List<URL> getURLsFromDirectory(File repository, String pattern)
repository
- repertoire dans lequel on recherche les fichierspattern
- le nom du fichier a extraire du fichier du repertoire doit
correspondre au pattern (repertoire + nom compris). si le
pattern est null, tous les fichiers trouvé sont retourné.public static boolean isJar(String name)
name
- nom du fichier a testerpublic static boolean isZip(String name)
name
- nom du fichier a testerpublic static boolean containsDirectDirectory(URL url, String directory) throws IOException
url
- the url to seekdirectory
- the directory to findtrue
if directory was found, false
otherwise.IOException
- if any io pbprotected static boolean isPattern(String str)
str
is a pattern (contains * or ?).str
- str to testtrue
if str
is a pattern, false
otherwisepublic static List<URL> getResources(String pattern) throws IOException
ClassLoader.getSystemClassLoader()
.
Usage :
List<URL> urls = Resources.getResources("META-INF/.\*\.MF"); List<URL> urls = Resources.getResources("org/nuiton/util/.?esource\\.class");
pattern
- java regex style pattern to findIOException
- if any IO problem while seeking resourcespublic static List<URL> getResources(String pattern, ClassLoader classLoader) throws IOException
List<URL> urls = Resources.getResources("META-INF/.\*\.MF"); List<URL> urls = Resources.getResources("org/nuiton/util/.?esource\\.class");
pattern
- java regex style pattern to findclassLoader
- classLoaderIOException
- if any IO problem while seeking resourcesprotected static List<URL> getPatternRessources(String pattern, ClassLoader classLoader) throws IOException
pattern
- pattern of searched resourcesclassLoader
- class loader which responsible to seek resourcesIOException
- if any IO problem while scanning resourcespublic static boolean isJarUrl(URL url)
url
- url to testprotected static List<URL> doFindPathMatchingJarResources(URL rootDirResource, String subPattern) throws IOException
rootDirResource
- the root directory as ResourcesubPattern
- the sub pattern to match (below the root directory)IOException
- in case of I/O errorsJarURLConnection
protected static List<URL> doFindMatchingFileSystemResources(URL rootDirResource, String subPattern) throws IOException
rootDirResource
- the root directory as ResourcesubPattern
- the sub pattern to match (below the root directory)IOException
- in case of I/O errorsretrieveMatchingFiles(File, String)
protected static List<URL> retrieveMatchingFiles(File rootDir, String pattern) throws IOException
rootDir
- the directory to start frompattern
- the pattern to match against,
relative to the root directoryIOException
- if directory contents could not be retrievedprotected static void doRetrieveMatchingFiles(String fullPattern, File dir, List<URL> result) throws IOException
fullPattern
- the pattern to match against,
with preprended root directory pathdir
- the current directoryresult
- the Set of matching File instances to add toIOException
- if directory contents could not be retrievedCopyright © 2004–2020 CodeLutin. All rights reserved.