mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
flesh out resource URL scheme implementation
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
package java.lang;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public abstract class ClassLoader {
|
||||
private final ClassLoader parent;
|
||||
|
||||
@ -75,4 +79,38 @@ public abstract class ClassLoader {
|
||||
private ClassLoader getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
protected URL findResource(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public URL getResource(String path) {
|
||||
URL url = null;
|
||||
if (parent != null) {
|
||||
url = parent.getResource(path);
|
||||
}
|
||||
|
||||
if (url == null) {
|
||||
url = findResource(path);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public InputStream getResourceAsStream(String path) {
|
||||
URL url = getResource(path);
|
||||
try {
|
||||
return (url == null ? null : url.openStream());
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static URL getSystemResource(String path) {
|
||||
return getSystemClassLoader().getResource(path);
|
||||
}
|
||||
|
||||
public static InputStream getSystemResourceAsStream(String path) {
|
||||
return getSystemClassLoader().getResourceAsStream(path);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user