如何创建从数据库中获取的图片的路径并保存到文件夹中?

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

我正在尝试使用 java 从 postgresql 中的数据库中获取图像,我想知道如何为该图像创建命名路由(示例 C:/images/pic.png ) ,这就是我从数据库中获取图像的方式。

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);

谢谢。

如何将图像/图片保存到数据库中?你为此使用另一个脚本吗?还是您手动保存?我建议您应该专门为 pathlocation 开辟一个专栏,以便您将来可以参考它。每当您上传/保存照片时,请在该栏中包含您需要的信息。

这个 answer 也可能对您有所帮助。