#Automatically search for files without knowing the filepath of the program?

1 messages · Page 1 of 1 (latest)

rapid quailBOT
#

<@&987246883653156906> please have a look, thanks.

kind relic
#

^^ Dont mind the "ui" folder in the filepath I was just trying something there, plain "interface.txt" did not work either

old oxide
kind relic
#

Hi guys, I am facing an issue with the code which was provided earlier in here and I dont know how to resolve it. ``` public void userGui() {

    try (InputStream in = getClass().getResourceAsStream("interface.txt");
            BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {

            System.out.println(reader);
        
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    
}``` Throws a nullpointer, i will provide my project tree below.
#

I don’t know where to put the interface.txt so Java can see it

dry condor
sudden sapphire
dry condor
#

ah

#

you just want to display an image ?

#

it should be in source/resource

#

and the path should be /interface.txt

#

@kind relic

kind relic
kind relic
kind relic
dry condor
kind relic
#

Ok so like I did basically

#

Oh wait nvm I put it in project folder

kind relic
#

Worked, thank you guys