Package libcore.io
Class ClassPathURLStreamHandler
- java.lang.Object
-
- java.net.URLStreamHandler
-
- libcore.net.url.JarHandler
-
- libcore.io.ClassPathURLStreamHandler
-
public class ClassPathURLStreamHandler extends JarHandler
AURLStreamHandlerfor a specific class pathJarFile. This class avoids the need to open a jar file multiple times to read resources if the jar file can be held open. TheURLConnectionobjects created are a subclass ofJarURLConnection.Use
getEntryUrlOrNull(String)to obtain a URL backed by this stream handler.
-
-
Constructor Summary
Constructors Constructor Description ClassPathURLStreamHandler(String jarFileName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Used from tests to indicate this stream handler is finished with.URLgetEntryUrlOrNull(String entryName)Returns a URL backed by this stream handler for the named resource, ornullif the entry cannot be found under the exact name presented.booleanisEntryStored(String entryName)Returns true if an entry with the specified name exists and is stored (not compressed), and false otherwise.protected URLConnectionopenConnection(URL url)Returns a connection to the jar file pointed by thisURLin the file system-
Methods inherited from class libcore.net.url.JarHandler
parseURL, toExternalForm
-
Methods inherited from class java.net.URLStreamHandler
equals, getDefaultPort, getHostAddress, hashCode, hostsEqual, openConnection, sameFile, setURL, setURL
-
-
-
-
Constructor Detail
-
ClassPathURLStreamHandler
public ClassPathURLStreamHandler(String jarFileName) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getEntryUrlOrNull
public URL getEntryUrlOrNull(String entryName)
Returns a URL backed by this stream handler for the named resource, ornullif the entry cannot be found under the exact name presented.
-
isEntryStored
public boolean isEntryStored(String entryName)
Returns true if an entry with the specified name exists and is stored (not compressed), and false otherwise.
-
openConnection
protected URLConnection openConnection(URL url) throws IOException
Description copied from class:JarHandlerReturns a connection to the jar file pointed by thisURLin the file system- Overrides:
openConnectionin classJarHandler- Parameters:
url- java.net.URL The URL to which the connection is pointing to- Returns:
- java.net.URLConnection A connection to the resource pointed by this url.
- Throws:
IOException- thrown if an IO error occurs when this method tries to establish connection.
-
close
public void close() throws IOExceptionUsed from tests to indicate this stream handler is finished with.- Throws:
IOException
-
-