2020-02-23 23:17:21 +01:00
|
|
|
package inf112.fiasko.roborally.utility;
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
2020-02-25 16:58:15 +01:00
|
|
|
public final class ResourceUtil {
|
2020-02-23 23:17:21 +01:00
|
|
|
private ResourceUtil() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an input stream for a given resource
|
|
|
|
* @param resourcePath The relative path from the resources folder to the resource
|
|
|
|
* @return An input stream
|
|
|
|
*/
|
|
|
|
public static InputStream getResourceAsInputStream(String resourcePath) {
|
|
|
|
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
|
|
|
|
InputStream resourceStream = classloader.getResourceAsStream(resourcePath);
|
|
|
|
if (resourceStream == null) {
|
|
|
|
throw new IllegalArgumentException("Unable to load resource.");
|
|
|
|
}
|
|
|
|
return resourceStream;
|
|
|
|
}
|
|
|
|
}
|