简体   繁体   中英

how to create a path to a picture taken from a database and saved a folder?

I'm trying to grab an image from a database in postgresql using java and I would like to know how to create a named route for that image (example C: /images/pic.png) ,this is how I take the image from the database.

InputStream is;
ImageIcon foto;
is =  results.getBinaryStream(i+1);
BufferedImage bi = ImageIO.read(is);
foto = new ImageIcon(bi);
Image img = foto.getImage();
Image newimg = img.getScaledInstance(140, 170, java.awt.Image.SCALE_SMOOTH);
ImageIcon newicon = new ImageIcon(newimg);

Thanks.

How does the images / pictures saved to the database? are you using another script for that? or are you manually saving it? I suggest that you should dedicate another column just for the path or location so that you could just refer to it in the future. Whenever you upload / save the photo, include the information you need in that column.

This answer may also help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM