Package gnu.text
Class ResourceStreamHandler
- java.lang.Object
-
- java.net.URLStreamHandler
-
- gnu.text.ResourceStreamHandler
-
public class ResourceStreamHandler extends URLStreamHandler
Handler for"class-resource:"
URLs. These are "indirect URLs" implemented using ClassLoader.getResource(). Their syntax is: either:class-resource:/PACKAGE/CLASS
orclass-resource:/CLASS
orclass-resource:/PACKAGE/RESOURCE
orclass-resource:/RESOURCE
. The former two are "base URLs" which need to be resolved. The latter two are resolved resource names. Levels of aPACKAGE
are separated by'.'
, not'/'
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLASS_RESOURCE_URI_PREFIX
A special URI-scheme for accessing resources relative to a ClassLoader.static int
CLASS_RESOURCE_URI_PREFIX_LENGTH
The length of CLASS_RESOURCE_URI_PREFIX, including ":/".
-
Constructor Summary
Constructors Constructor Description ResourceStreamHandler(Class clas)
ResourceStreamHandler(ClassLoader cloader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static URL
makeURL(Class clas)
URLConnection
openConnection(URL u)
-
Methods inherited from class java.net.URLStreamHandler
equals, getDefaultPort, getHostAddress, hashCode, hostsEqual, openConnection, parseURL, sameFile, setURL, setURL, toExternalForm
-
-
-
-
Field Detail
-
CLASS_RESOURCE_URI_PREFIX
public static final String CLASS_RESOURCE_URI_PREFIX
A special URI-scheme for accessing resources relative to a ClassLoader. The resource is found using ClassLoader's getResource method. The actual ClassLoader is found using getClassLoaderForURI.- See Also:
- Constant Field Values
-
CLASS_RESOURCE_URI_PREFIX_LENGTH
public static final int CLASS_RESOURCE_URI_PREFIX_LENGTH
The length of CLASS_RESOURCE_URI_PREFIX, including ":/".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ResourceStreamHandler
public ResourceStreamHandler(Class clas)
-
ResourceStreamHandler
public ResourceStreamHandler(ClassLoader cloader)
-
-
Method Detail
-
makeURL
public static URL makeURL(Class clas) throws MalformedURLException
- Throws:
MalformedURLException
-
openConnection
public URLConnection openConnection(URL u) throws IOException
- Specified by:
openConnection
in classURLStreamHandler
- Throws:
IOException
-
-