本文整理汇总了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;
}