You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
38 lines
1.0 KiB
package com.sothr.imagetools.engine.util;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import java.io.InputStream;
|
|
import java.net.URL;
|
|
|
|
/**
|
|
* Seamlessly handle resource loading
|
|
*
|
|
* Created by drew on 1/5/14.
|
|
*/
|
|
public class ResourceLoader {
|
|
|
|
private static final ResourceLoader instance = new ResourceLoader();
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
private ResourceLoader() {
|
|
logger.info("Created Resource Loader");
|
|
}
|
|
|
|
public static ResourceLoader get() {
|
|
return instance;
|
|
}
|
|
|
|
public URL getResource(String location) {
|
|
logger.debug(String.format("Attempting to load resource: %s", location));
|
|
return Thread.currentThread().getContextClassLoader().getResource(location);
|
|
}
|
|
|
|
public InputStream getResourceStream(String location) {
|
|
logger.debug(String.format("Attempting to get stream for resource: %s",location));
|
|
return Thread.currentThread().getContextClassLoader().getResourceAsStream(location);
|
|
}
|
|
|
|
}
|