本文整理了Java中java.lang.ClassLoader.getSystemResourceAsStream()
方法的一些代码示例,展示了ClassLoader.getSystemResourceAsStream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassLoader.getSystemResourceAsStream()
方法的具体详情如下:
包路径:java.lang.ClassLoader
类名称:ClassLoader
方法名:getSystemResourceAsStream
[英]Returns a stream for the resource with the specified name. The system class loader's resource lookup algorithm is used to find the resource. Basically, the contents of the java.class.path are searched in order, looking for a path which matches the specified resource.
[中]返回具有指定名称的资源的流。系统类加载器的资源查找算法用于查找资源。基本上是java的内容。班按顺序搜索路径,查找与指定资源匹配的路径。
代码示例来源:origin: prestodb/presto
public InputStream run() {
if (iLoader != null) {
return iLoader.getResourceAsStream(path);
} else {
return ClassLoader.getSystemResourceAsStream(path);
}
}
});
代码示例来源:origin: commons-logging/commons-logging
public Object run() {
ClassLoader threadCL = getContextClassLoader();
if (threadCL != null) {
return threadCL.getResourceAsStream(name);
} else {
return ClassLoader.getSystemResourceAsStream(name);
}
}
});
代码示例来源:origin: commons-logging/commons-logging
public Object run() {
if (loader != null) {
return loader.getResourceAsStream(name);
} else {
return ClassLoader.getSystemResourceAsStream(name);
}
}
});
代码示例来源:origin: apache/rocketmq
protected static InputStream getResourceAsStream(ClassLoader loader, String name) {
if (loader != null) {
return loader.getResourceAsStream(name);
} else {
return ClassLoader.getSystemResourceAsStream(name);
}
}
代码示例来源:origin: google/j2objc
/**
* Constructs a new {@link ClassReader} object.
*
* @param name the fully qualified name of the class to be read.
* @throws IOException if an exception occurs during reading.
*/
public ClassReader(final String name) throws IOException {
this(ClassLoader.getSystemResourceAsStream(name.replace('.', '/')
+ ".class"));
}
代码示例来源:origin: joda-time/joda-time
public InputStream run() {
if (iLoader != null) {
return iLoader.getResourceAsStream(path);
} else {
return ClassLoader.getSystemResourceAsStream(path);
}
}
});
代码示例来源:origin: org.slf4j/jcl-over-slf4j
public InputStream run() {
ClassLoader threadCL = getContextClassLoader();
if (threadCL != null) {
return threadCL.getResourceAsStream(name);
} else {
return ClassLoader.getSystemResourceAsStream(name);
}
}
});
代码示例来源:origin: JodaOrg/joda-time
public InputStream run() {
if (iLoader != null) {
return iLoader.getResourceAsStream(path);
} else {
return ClassLoader.getSystemResourceAsStream(path);
}
}
});
代码示例来源:origin: spring-projects/spring-framework
/**
* Constructs a new {@link ClassReader} object.
*
* @param className the fully qualified name of the class to be read. The ClassFile structure is
* retrieved with the current class loader's {@link ClassLoader#getSystemResourceAsStream}.
* @throws IOException if an exception occurs during reading.
*/
public ClassReader(final String className) throws IOException {
this(
readStream(
ClassLoader.getSystemResourceAsStream(className.replace('.', '/') + ".class"), true));
}
代码示例来源:origin: redisson/redisson
public InputStream run() {
ClassLoader threadCL = Thread.currentThread().getContextClassLoader();
if (threadCL != null) {
return threadCL.getResourceAsStream(CONFIGURATION_FILE);
} else {
return ClassLoader.getSystemResourceAsStream(CONFIGURATION_FILE);
}
}
});
代码示例来源:origin: weibocom/motan
private static void loadProperties() {
try {
properties.load(ClassLoader.getSystemResourceAsStream("benchmark.properties"));
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: redisson/redisson
/**
* Constructs a new {@link ClassReader} object.
*
* @param className the fully qualified name of the class to be read. The ClassFile structure is
* retrieved with the current class loader's {@link ClassLoader#getSystemResourceAsStream}.
* @throws IOException if an exception occurs during reading.
*/
public ClassReader(final String className) throws IOException {
this(
readStream(
ClassLoader.getSystemResourceAsStream(className.replace('.', '/') + ".class"), true));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* This implementation opens an InputStream for the given class path resource.
* @see java.lang.ClassLoader#getResourceAsStream(String)
* @see java.lang.Class#getResourceAsStream(String)
*/
@Override
public InputStream getInputStream() throws IOException {
InputStream is;
if (this.clazz != null) {
is = this.clazz.getResourceAsStream(this.path);
}
else if (this.classLoader != null) {
is = this.classLoader.getResourceAsStream(this.path);
}
else {
is = ClassLoader.getSystemResourceAsStream(this.path);
}
if (is == null) {
throw new FileNotFoundException(getDescription() + " cannot be opened because it does not exist");
}
return is;
}
代码示例来源:origin: neo4j/neo4j
private static String readResourceAsString( String resource )
{
return readAsString( ClassLoader.getSystemResourceAsStream( resource ) );
}
代码示例来源:origin: org.springframework/spring-core
/**
* Constructs a new {@link ClassReader} object.
*
* @param className the fully qualified name of the class to be read. The ClassFile structure is
* retrieved with the current class loader's {@link ClassLoader#getSystemResourceAsStream}.
* @throws IOException if an exception occurs during reading.
*/
public ClassReader(final String className) throws IOException {
this(
readStream(
ClassLoader.getSystemResourceAsStream(className.replace('.', '/') + ".class"), true));
}
代码示例来源:origin: json-path/JsonPath
@Test
public void testConcatResultSet() {
InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
String concatResult = JsonPath.parse(stream).read("$.concat($..state)", String.class);
assertEquals("Expected a string length to be a concat of all of the states", concatResult.length(), 806);
}
代码示例来源:origin: json-path/JsonPath
@Test
public void testConcatWithNumericValueAsString() {
InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
String concatResult = JsonPath.parse(stream).read("$.concat($..cpus)", String.class);
assertEquals("Expected a string length to be a concat of all of the cpus", concatResult.length(), 489);
}
}
代码示例来源:origin: json-path/JsonPath
@Test
public void testResultSetNumericComputation() {
InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
Long value = JsonPath.parse(stream).read("$.sum($..timestamp)", Long.class);
assertEquals("Expected the max function to consume the aggregation parameters and calculate the max over the result set",
Long.valueOf(35679716813L), value);
}
代码示例来源:origin: json-path/JsonPath
@Test
public void testResultSetNumericComputationRecursiveReplacement() {
InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
Long value = JsonPath.parse(stream).read("$.max($..timestamp.avg(), $..timestamp.stddev())", Long.class);
assertEquals("Expected the max function to consume the aggregation parameters and calculate the max over the result set",
Long.valueOf(1427188672L), value);
}
代码示例来源:origin: json-path/JsonPath
@Test
public void testResultSetNumericComputationTail() {
InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
Long value = JsonPath.parse(stream).read("$..timestamp.sum()", Long.class);
assertEquals("Expected the max function to consume the aggregation parameters and calculate the max over the result set",
Long.valueOf(35679716813L), value);
}
内容来源于网络,如有侵权,请联系作者删除!