
uk.co.mruoc.properties.ClasspathInputStreamLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of file-loader Show documentation
Show all versions of file-loader Show documentation
Code library to easily load files and file from the classpath or file system file
package uk.co.mruoc.properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
public class ClasspathInputStreamLoader implements InputStreamLoader {
private static final Logger LOGGER = LoggerFactory.getLogger(ClasspathInputStreamLoader.class);
@Override
public InputStream load(String path) {
LOGGER.debug("loading input stream from classpath using path " + path);
InputStream stream = getClass().getResourceAsStream(path);
if (stream == null) {
throw new UncheckedIOException(new IOException("file not found on classpath at " + path));
}
return stream;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy