The Problem
I am loading a yaml-configuration in a Minecraft-Server plugin, but it can't find the file / returns null. I tried everything.
I checked if the file also exists in the jar
-file and renamed the file to game_settings.yml.txt
, too, but with no success.
My package structure
+- src [resource root]
+- my.package
+- MyClass.java
+- game_settings.yml
What I tried
this.getClass().getResourceAsStream("game_settings.yml"); // null
MyClass.class.getResourceAsStream("game_settings.yml"); // null
MyClass.class.getClass().getResourceAsStream("game_settings.yml"); // null
this.getClass().getClassLoader().getResourceAsStream("game_settings.yml"); // null
The weird thing is that when I use getResource()
, it always finds the path. So Java actually knows that the file is there.
EDIT: The file is not found in the package, but I can see it in the jar. Why is the file invisible for Java?