put inputstream in try body so it can be autoclosed

This commit is contained in:
igoudt 2017-04-26 11:19:52 +02:00
parent 0528555075
commit 3f47d5a253

View file

@ -140,13 +140,8 @@ public final class ImageHelper {
* @return
*/
public static Image getImageFromResources(String path) {
InputStream stream;
stream = UI.class.getResourceAsStream(path);
if (stream == null) {
throw new IllegalArgumentException("Couldn't find image in resources: " + path);
}
try {
try(InputStream stream = UI.class.getResourceAsStream(path)) {
ImageIO.setUseCache(false);
BufferedImage image = ImageIO.read(stream);
return image;