forked from jzitnik/twodcraft
23 lines
700 B
Java
23 lines
700 B
Java
package cz.jzitnik.tui;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
public class ResourceLoader {
|
|
public static String loadResource(String fileName) {
|
|
try (InputStream inputStream = ResourceLoader.class.getClassLoader().getResourceAsStream("textures/"+fileName)) {
|
|
if (inputStream == null) {
|
|
// If the file is not found, return null
|
|
return null;
|
|
}
|
|
|
|
byte[] bytes = inputStream.readAllBytes();
|
|
return new String(bytes, StandardCharsets.UTF_8);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
}
|