mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-08 19:19:35 +01:00
22 lines
720 B
Java
22 lines
720 B
Java
|
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;
|
||
|
}
|
||
|
}
|