Java getResourceAsStream as local resource
Posted
by
Dajgoro Labinac
on Game Development
See other posts from Game Development
or by Dajgoro Labinac
Published on 2012-08-28T02:03:55Z
Indexed on
2012/08/28
9:51 UTC
Read the original article
Hit count: 219
Before using LWJGL, I used the Graphic
method, and there I displayed imageicons
, and I had the picture file located in the resources.
I used:
ImageIcon tcard = new ImageIcon(this.getClass().getResource("RCA.png"));
to load the image.
Now when I load textures in LWJGL, I have to use absolute paths to locate the file:
tcard = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("C:/RCA.png"));
I tried Googling, but I didn't find anything helpful. How can I load the image from the local resources like in the first example?
© Game Development or respective owner