0
我必须将图像URL转换为图像。为此,我尝试了将base64转换为图像的编码。在调试代码后,“Bufferedimage image”在ByteArrayInputStream bis=new ByteArrayInputStream(imagebyte)
之后始终为空。我能做什么?如何将Base64(imageurl)转换为图像
String imageStr = request.getParameter("imgURL");
BufferedImage image = null;
try {
BASE64Decoder decoder = new BASE64Decoder();
byte[] imageByte = decoder.decodeBuffer(imageStr);
ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
image = ImageIO.read(bis);
File outputfile = new File("E:\\saved.png");
ImageIO.write(image, "png", outputfile);
bis.close();
} catch (Exception e) {
e.printStackTrace();
}
您试图将URL解码为图像。该URL会告诉你图像在哪里! – kutschkem
请参阅[此答案](http://stackoverflow.com/a/10132345/418556)。如果你不能从中获益,请发布[SSCCE](http://sscce.org/)。 –