Java - How to load resources form the source folder with gradle and Intelij

687 Views Asked by At

I'm using Gradle and IntelliJ. I have a project with the following structure:

MyProject
   -src
     -main
       -java
         -com
           -app
             -resources
               -myfile.json

I want to read myfile.json, but there is no way to make it work. I already know that I can create the resource folder, using the resource folder works properly. But this is a legacy project and I can't change it right now.

I'm using the following to load the resource

Thread.currentThread().getClass().getResourceAsStream("/com/app/resources/myfile.json")

But I was not able to make it work. I've even changed my configuration Intelij like this Intelij Configuration

0

There are 0 best solutions below