#how do I load an image from resources folder?
1 messages · Page 1 of 1 (latest)
<@&987246487241105418> please have a look, thanks.
getClass().getResourceAsStream("/foo.png")
you get an input stream, then do whatever you want from it
I need it as an image though
you can easily read this input stream into an image, no matter which which image class you are talking about
getResource and getResourceAsStream provides a URL you can use to obtain the resource
you would use the URL to load whatever resource you need. if you need an image, you'd load the image as you would any other image
you'd just be using the URL to locate the image
getResourceAsStream is better imo, most image loading classes like ImageIO accept InputStream