public class ClassPathURLStreamHandler extends JarHandler
URLStreamHandler for a specific class path JarFile. This class avoids the need
to open a jar file multiple times to read resources if the jar file can be held open. The
URLConnection objects created are a subclass of JarURLConnection.
Use getEntryUrlOrNull(String) to obtain a URL backed by this stream handler.
| Constructor and Description |
|---|
ClassPathURLStreamHandler(String jarFileName) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Used from tests to indicate this stream handler is finished with.
|
URL |
getEntryUrlOrNull(String entryName)
Returns a URL backed by this stream handler for the named resource, or
null if the
entry cannot be found under the exact name presented. |
boolean |
isEntryStored(String entryName)
Returns true if an entry with the specified name exists and is stored (not compressed),
and false otherwise.
|
protected URLConnection |
openConnection(URL url)
Returns a connection to the jar file pointed by this
URL
in the file system |
parseURL, toExternalFormequals, getDefaultPort, getHostAddress, hashCode, hostsEqual, openConnection, sameFile, setURL, setURLpublic ClassPathURLStreamHandler(String jarFileName) throws IOException
IOExceptionpublic URL getEntryUrlOrNull(String entryName)
null if the
entry cannot be found under the exact name presented.public boolean isEntryStored(String entryName)
protected URLConnection openConnection(URL url) throws IOException
JarHandlerURL
in the file systemopenConnection in class JarHandlerurl - java.net.URL The URL to which the connection is pointing toIOException - thrown if an IO error occurs when this method tries to
establish connection.public void close()
throws IOException
IOException