public class ResourceUtils extends Object
Constructor and Description |
---|
ResourceUtils() |
Modifier and Type | Method and Description |
---|---|
static File |
getClasspathAsFolder(String aClasspathBase,
boolean aCache)
Make a given classpath location available as a folder.
|
static File |
getUrlAsExecutable(URL aUrl,
boolean aCache)
Make the given URL available as an executable file.
|
static File |
getUrlAsFile(URL aUrl,
boolean aCache)
Make the given URL available as a file.
|
static File |
getUrlAsFile(URL aUrl,
boolean aCache,
boolean aForceTemp)
Make the given URL available as a file.
|
static InputStream |
resolveCompressedInputStream(InputStream is,
String filename)
Deprecated.
|
static URL |
resolveLocation(String aLocation)
Resolve a location (which can be many things) to an URL.
|
static URL |
resolveLocation(String aLocation,
ClassLoader aClassLoader,
org.apache.uima.UimaContext aContext)
Resolve a location (which can be many things) to an URL.
|
static URL |
resolveLocation(String aLocation,
Object aCaller,
org.apache.uima.UimaContext aContext)
Resolve a location (which can be many things) to an URL.
|
static URL |
resolveLocation(String aLocation,
org.apache.uima.UimaContext aContext)
Resolve a location (which can be many things) to an URL.
|
public static File getClasspathAsFolder(String aClasspathBase, boolean aCache) throws IOException
aClasspathBase
- a classpath location as used by
PathMatchingResourcePatternResolver.getResources(String)
aCache
- use the cache or not.IOException
- if an I/O error has occurred,PathMatchingResourcePatternResolver
public static File getUrlAsFile(URL aUrl, boolean aCache) throws IOException
aCache
is true
, the temporary
file is remembered in a cache and if a file is requested for the same URL at a later time,
the same file is returned again. If the previously created file has been deleted meanwhile,
it is recreated from the URL. This method should not be used for creating executable
binaries. For this purpose, getUrlAsExecutable should be used.aUrl
- the URL.aCache
- use the cache or not.IOException
- if the URL cannot be accessed to (re)create the file.public static File getUrlAsFile(URL aUrl, boolean aCache, boolean aForceTemp) throws IOException
aCache
is true
, the temporary
file is remembered in a cache and if a file is requested for the same URL at a later time,
the same file is returned again. If the previously created file has been deleted meanwhile,
it is recreated from the URL. This method should not be used for creating executable
binaries. For this purpose, getUrlAsExecutable should be used.aUrl
- the URL.aCache
- use the cache or not.aForceTemp
- always create a temporary file, even if the URL is already a file.IOException
- if the URL cannot be accessed to (re)create the file.public static File getUrlAsExecutable(URL aUrl, boolean aCache) throws IOException
aCache
is true
, the
temporary file is remembered in a cache and if a file is requested for the same URL at a
later time, the same file is returned again. If the previously created file has been deleted
meanwhile, it is recreated from the URL.aUrl
- the URL.aCache
- use the cache or not.IOException
- if the file has permissions issues.@Deprecated public static InputStream resolveCompressedInputStream(InputStream is, String filename) throws IOException
CompressionUtils.getInputStream(String, InputStream)
is
- An InputStream
.filename
- The filename this stream was created from.InputStream
IOException
- if something went wrong during resolving the input streampublic static URL resolveLocation(String aLocation) throws IOException
classpath:
the location is interpreted as a classpath location. Otherwise it is tried
as a URL, file and at last UIMA resource. If the location is treated as a classpath or file
location, an URL is only returned if the target exists. If it is an URL, it is possible that
the target may not actually exist.aLocation
- a location (classpath, URL, file or UIMA resource location).IOException
- if the target could not be found.public static URL resolveLocation(String aLocation, org.apache.uima.UimaContext aContext) throws IOException
classpath:
the location is interpreted as a classpath location. Otherwise it is tried
as a URL, file and at last UIMA resource. If the location is treated as a classpath or file
location, an URL is only returned if the target exists. If it is an URL, it is possible that
the target may not actually exist.aLocation
- a location (classpath, URL, file or UIMA resource location).aContext
- a UIMA context.IOException
- if the target could not be found.public static URL resolveLocation(String aLocation, Object aCaller, org.apache.uima.UimaContext aContext) throws IOException
classpath:
the location is interpreted as a classpath location. Otherwise it is tried
as a URL, file and at last UIMA resource. If the location is treated as a classpath or file
location, an URL is only returned if the target exists. If it is an URL, it is possible that
the target may not actually exist.aLocation
- a location (classpath, URL, file or UIMA resource location).aCaller
- the instance calling this method (for classpath loading).aContext
- a UIMA context.IOException
- if the target could not be found.public static URL resolveLocation(String aLocation, ClassLoader aClassLoader, org.apache.uima.UimaContext aContext) throws IOException
classpath:
the location is interpreted as a classpath location. Otherwise it is tried
as a URL, file and at last UIMA resource. If the location is treated as a classpath or file
location, an URL is only returned if the target exists. If it is an URL, it is possible that
the target may not actually exist.aLocation
- a location (classpath, URL, file or UIMA resource location).aClassLoader
- the class loader to be used for classpath URLs.aContext
- a UIMA context.IOException
- if the target could not be found.Copyright © 2007–2018 Ubiquitous Knowledge Processing (UKP) Lab, Technische Universität Darmstadt. All rights reserved.