
org.snapscript.common.store.ClassPathLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
The newest version!
package org.snapscript.common.store;
import java.io.InputStream;
public class ClassPathLoader {
private final Class type;
public ClassPathLoader(Class type) {
this.type = type;
}
public InputStream loadResource(String path) {
Thread thread = Thread.currentThread();
ClassLoader context = thread.getContextClassLoader();
InputStream source = context.getResourceAsStream(path);
if(source == null) {
ClassLoader caller = type.getClassLoader();
if(caller != context) {
return caller.getResourceAsStream(path);
}
}
return source;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy