public class ResourceUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CLASSPATH_URL_PREFIX |
static String |
FILE_URL_PREFIX |
static String |
JAR_FILE_SUFFIX |
static String |
JAR_URL_PREFIX |
static String |
JAR_URL_SEPARATOR |
static String |
PATH_SPEPARATOR |
static char |
PATH_SPEPARATOR_CHAR |
static String |
URL_PROTOCOL_CODE_SOURCE |
static String |
URL_PROTOCOL_FILE |
static String |
URL_PROTOCOL_JAR |
static String |
URL_PROTOCOL_VFSZIP |
static String |
URL_PROTOCOL_WSJAR |
static String |
URL_PROTOCOL_ZIP |
static String |
ZIP_FILE_SUFFIX |
Constructor and Description |
---|
ResourceUtils() |
Modifier and Type | Method and Description |
---|---|
static URL |
extractJarFileURL(URL jarUrl) |
static File |
getFile(String resourceLocation,
ClassLoader classLoader) |
static File |
getFile(URI resourceUri) |
static File |
getFile(URI resourceUri,
String description) |
static File |
getFile(URL resourceUrl) |
static File |
getFile(URL resourceUrl,
String description) |
static Reader |
getReader(File file,
String encoding)
Returns a Reader for reading the specified file.
|
static Reader |
getReader(URL url,
String encoding)
Returns a Reader for reading the specified url.
|
static InputStream |
getResourceAsStream(String resource,
ClassLoader classLoader)
Returns a resource on the classpath as a Stream object.
|
static URL |
getResourceURL(String resource,
ClassLoader loader)
Returns the URL of the resource on the classpath.
|
static URL |
getURL(String resourceLocation,
ClassLoader classLoader) |
static boolean |
isJarSimilarURL(URL url) |
static boolean |
isJarURL(URL url) |
static boolean |
isUrl(String resourceLocation) |
static String |
read(File file,
String encoding)
Returns a string from the specified file.
|
static String |
read(Reader reader)
Returns a string from the specified Reader object.
|
static String |
read(URL url,
String encoding)
Returns a string from the specified url.
|
static URI |
toURI(String location) |
static URI |
toURI(URL url) |
public static final String CLASSPATH_URL_PREFIX
public static final String FILE_URL_PREFIX
public static final String JAR_URL_PREFIX
public static final String JAR_FILE_SUFFIX
public static final String ZIP_FILE_SUFFIX
public static final String URL_PROTOCOL_FILE
public static final String URL_PROTOCOL_JAR
public static final String URL_PROTOCOL_ZIP
public static final String URL_PROTOCOL_VFSZIP
public static final String URL_PROTOCOL_WSJAR
public static final String URL_PROTOCOL_CODE_SOURCE
public static final String JAR_URL_SEPARATOR
public static final String PATH_SPEPARATOR
public static final char PATH_SPEPARATOR_CHAR
public static boolean isUrl(String resourceLocation)
public static URL getURL(String resourceLocation, ClassLoader classLoader) throws FileNotFoundException
FileNotFoundException
public static File getFile(String resourceLocation, ClassLoader classLoader) throws FileNotFoundException
FileNotFoundException
public static File getFile(URL resourceUrl) throws FileNotFoundException
FileNotFoundException
public static File getFile(URL resourceUrl, String description) throws FileNotFoundException
FileNotFoundException
public static File getFile(URI resourceUri) throws FileNotFoundException
FileNotFoundException
public static File getFile(URI resourceUri, String description) throws FileNotFoundException
FileNotFoundException
public static boolean isJarURL(URL url)
public static boolean isJarSimilarURL(URL url)
public static URL extractJarFileURL(URL jarUrl) throws MalformedURLException
MalformedURLException
public static URI toURI(URL url) throws URISyntaxException
URISyntaxException
public static URI toURI(String location) throws URISyntaxException
URISyntaxException
public static URL getResourceURL(String resource, ClassLoader loader) throws IOException
loader
- The classloader used to load the resourceresource
- The resource to findIOException
- If the resource cannot be found or readpublic static InputStream getResourceAsStream(String resource, ClassLoader classLoader) throws IOException
resource
- The resource to findclassLoader
- the class loaderIOException
- If the resource cannot be found or readpublic static Reader getReader(File file, String encoding) throws IOException
file
- the fileencoding
- the encodingIOException
- if an error occurred when reading resources using any I/O operationspublic static Reader getReader(URL url, String encoding) throws IOException
url
- the urlencoding
- the encodingIOException
- if an error occurred when reading resources using any I/O operationspublic static String read(File file, String encoding) throws IOException
file
- the fileencoding
- the encodingIOException
- if an error occurred when reading resources using any I/O operationspublic static String read(URL url, String encoding) throws IOException
url
- the urlencoding
- the encodingIOException
- if an error occurred when reading resources using any I/O operationspublic static String read(Reader reader) throws IOException
reader
- the readerIOException
- if an error occurred when reading resources using any I/O operationsCopyright © 2008–2017 Aspectran.com. All rights reserved.