我正在尝试执行以下操作:http://www.codejava.net/java-se/jdbc/read-file-data-from-database-using-jdbc
除非不使用
OutputStream outputStream = new FileOutputStream(filePath);
和
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
我希望我可以创建一个图像数组列表并简单地将所有图像存储在其中?原因是我从数据库获取的图像都属于一个特定用户,我不希望它们保存在硬盘上的文件中。
最佳答案
您可以将图像存储为BufferedImage:
ArrayList< BufferedImage > listOfImages = new ArrayList< BufferedImage >();
if (result.next()) {
Blob blob = result.getBlob("photo");
listOfImages.add( javax.imageio.ImageIO.read( blob.getBinaryStream() ) );
}
关于java - SQL : Is there any way to read BLOBs from a database into an array instead of FileOutputStream in java?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46287005/