0
我有一个图像url(http://example.com/myimage.jpg),并希望将其转换为字节数组并将其保存在我的数据库中。请帮助我举一些例子。获取图像与给定的网址,并将其转换为字节数组
我做了以下内容,但得到这个消息URI scheme is not "file"
URI uri = new URI(profileImgUrl);
File fnew = new File(uri);
BufferedImage originalImage=ImageIO.read(fnew);
ByteArrayOutputStream baos=new ByteArrayOutputStream();
ImageIO.write(originalImage, "jpg", baos);
byte[] imageInByte=baos.toByteArray();
感谢!!!!!!!! – emilan
为什么不直接保存字节,通过图像进行确实是一个很大的开销? – ThomasRS