22 lines
720 B
Java
Raw Normal View History

2020-02-23 23:17:21 +01:00
package inf112.fiasko.roborally.utility;
import java.io.InputStream;
public class ResourceUtil {
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;
}
}