How can I read image from URL in Java?
URL url = new URL("http://www.digitalphotoartistry.com/rose1.jpg");
Image image = ImageIO.read(url);
or
URL url = new URL("http://www.digitalphotoartistry.com/rose1.jpg");
java.awt.Image image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
Update:
This code works for me Try checking your URL.
public static void main(String[] args) throws Exception {
URL imageURL = new URL("http://www.digitalphotoartistry.com/rose1.jpg");
// Case 1
RenderedImage img = ImageIO.read(imageURL);
System.out.println(img);
}
output:
BufferedImage@e80a59: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 col
or space = java.awt.color.ICC_ColorSpace@1ff5ea7 transparency = 1 has alpha = fa
lse isAlphaPre = false ByteInterleavedRaster: width = 553 height = 737 #numDataE
lements 3 dataOff[0] = 2