#Automatically search for files without knowing the filepath of the program?
1 messages · Page 1 of 1 (latest)
^^ Dont mind the "ui" folder in the filepath I was just trying something there, plain "interface.txt" did not work either
When we want to package images or other 'resources' with our code, java has a special resources folder you can put your assets in.
https://duckduckgo.com/?q=java+how+to+get+images+from+resource+folder&t=ffab&ia=web
DuckDuckGo. Privacy, Simplified.
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
What are you trying to do from it ?
I think this will help you
No, it depends of what he wants
ah
you just want to display an image ?
it should be in source/resource
and the path should be /interface.txt
@kind relic
ASCII yes
Ok I’ll try out later
so should I create a resource folder named resource in my project or
For now, put it in sources
Worked, thank you guys