Correct resource can't load from jar

This commit is contained in:
BrokenFire 2018-02-14 20:16:24 +01:00
parent 5e350ad89d
commit 9b522318e9

View File

@ -5,6 +5,7 @@ import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner; import java.util.Scanner;
@ -19,7 +20,7 @@ public class ResourceLoader {
//Get file from resources folder //Get file from resources folder
ClassLoader classLoader = getClass().getClassLoader(); ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource(fileName).getFile()); InputStream file = classLoader.getResourceAsStream(fileName);
try (Scanner scanner = new Scanner(file)) { try (Scanner scanner = new Scanner(file)) {
@ -30,8 +31,6 @@ public class ResourceLoader {
scanner.close(); scanner.close();
} catch (IOException e) {
logger.catching(e);
} }
return result.toString(); return result.toString();