+ 1

How to locally import an image in a java code, so that it would be possible to see the images even if the code gets exported?

Hellow fellow programmers, I need your help, I need to import images in a java code, but they are inside the code folder itself, so that, in case the program is exported to more users, they will be able to see the images once the code is initialized, I have already searched the internet how to import a local image, but there are many users saying different things, and honestly, I feel very confused about it, there are no tutorials about it within the site, as it would not be possible for users to work with images within the program implemented on the site (Although I think showing screenshots of the system file to show how and where to put the images can do the trick) So please would you be kind enough to explain: 1) Where to put the images to be imported in the program folder? 2) How to call the images inside the code? 3) How to interact with them?

10th May 2021, 4:12 PM
Nick
Nick - avatar
1 Odpowiedź
+ 1
What do you mean by importing and exporting images? Do you mean reading and writing .jpg, .png with the file system? Are you making a web application and want visitors to your website to download images saved in your web application's database? If you just need to read and write with common image file formats in the file system, look at the ImageIO class documented at: https://docs.oracle.com/javase/7/docs/api/javax/imageio/ImageIO.html It is in the standard Java API so you won't need any third-party jars or code. If you're writing code to edit the images such as resizing them, adding text to them... check classes like java.awt.Graphics, java.aawt.Graphics2D, BufferedImage which are also standard and work well with ImageIO.
12th May 2021, 6:53 AM
Josh Greig
Josh Greig - avatar