I have seen many examples on the Internet about how to convert a file to BufferedImage, but I need to do a counter conversion.
I tried several ways, but it's pretty complicated.
I wonder if there is a direct way to accomplish this.
I have this in my code:
for (FileItem item : formItems) {
if (!item.isFormField()) {
Date date = new Date();
String fileName = new File(item.getName()).getName();
String filePath = uploadPath + date.getTime() + fileName + ".tmp";
File storeFile = new File(filePath);
BufferedImage tempImg = ImageIO.read(storeFile);
item.write(tempImg);
}
}
I do not need to write FileItem, but the BufferedImage that I processed.
source
share