本文整理匯總了Java中jdk.internal.loader.URLClassPath.checkURL方法的典型用法代碼示例。如果您正苦於以下問題:Java URLClassPath.checkURL方法的具體用法?Java URLClassPath.checkURL怎麽用?Java URLClassPath.checkURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jdk.internal.loader.URLClassPath
的用法示例。
在下文中一共展示了URLClassPath.checkURL方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findResource
import jdk.internal.loader.URLClassPath; //導入方法依賴的package包/類
/**
* Finds the resource with the specified name on the URL search path.
*
* @param name the name of the resource
* @return a {@code URL} for the resource, or {@code null}
* if the resource could not be found, or if the loader is closed.
*/
public URL findResource(final String name) {
/*
* The same restriction to finding classes applies to resources
*/
URL url = AccessController.doPrivileged(
new PrivilegedAction<>() {
public URL run() {
return ucp.findResource(name, true);
}
}, acc);
return url != null ? URLClassPath.checkURL(url) : null;
}
示例2: findResource
import jdk.internal.loader.URLClassPath; //導入方法依賴的package包/類
/**
* Finds a resource in a module, returning {@code null} if the resource
* is not found.
*/
private static Resource findResource(String module, String name) {
if (reader != null) {
URL url = toJrtURL(module, name);
ImageLocation location = reader.findLocation(module, name);
if (location != null && URLClassPath.checkURL(url) != null) {
return new Resource() {
@Override
public String getName() {
return name;
}
@Override
public URL getURL() {
return url;
}
@Override
public URL getCodeSourceURL() {
return toJrtURL(module);
}
@Override
public InputStream getInputStream() throws IOException {
byte[] resource = reader.getResource(location);
return new ByteArrayInputStream(resource);
}
@Override
public int getContentLength() {
long size = location.getUncompressedSize();
return (size > Integer.MAX_VALUE) ? -1 : (int) size;
}
};
}
}
return null;
}