I want to read a json file in my java application which uses gradle. When I run the application in Intellij and gradle run it works fine, but when I do gradle dist and run that jar it throws a FileNotFound. If I open the jar with winrar I see the file in the correct directory.
I have tried getting the file in all ways I could find, some are:
new FileReader("data/user-data.json");
new FileReader(new File(getClass().getResource("data/user-data.json").getFile()));
new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("data/user-data.json")));
and lots more.
Can anyone help me? Let me know if you need more information.