public abstract class MemoryURLStreamHandler extends URLStreamHandler
URLStreamHandler
that implements the "memory" protocol. This class
can be used to create memory:/...
URLs that are resolvable in the JVM
in which they are created.Modifier and Type | Field and Description |
---|---|
protected static ConcurrentHashMap<String,byte[]> |
idToData |
Constructor and Description |
---|
MemoryURLStreamHandler() |
Modifier and Type | Method and Description |
---|---|
static URL |
createURL(byte[] data)
Returns a "memory" protocol
URL for the specified data . |
static byte[] |
getData(URL url)
Returns the data for the provided
URL . |
equals, getDefaultPort, getHostAddress, hashCode, hostsEqual, openConnection, openConnection, parseURL, sameFile, setURL, setURL, toExternalForm
protected static final ConcurrentHashMap<String,byte[]> idToData
public static URL createURL(byte[] data)
URL
for the specified data
.data
- The data byte
array.URL
for the specified data
.public static byte[] getData(URL url)
URL
.
Note: This method only supports URLs with "memory"
protocol,
and a null
or empty host.
url
- The URL
.URL
.IllegalArgumentException
- If the provided URL
specifies a
protocol that is not "memory"
, or a host that is not
null
or empty.NullPointerException
- If the provided URL
is null.Copyright © 2020 LibJ. All rights reserved.