saman
saman

Reputation: 91

how to parse the image from url SAX parsing

how do i parse the image form the link inside the xml file url.when i parse the data it shows me the link besides showing image. here is the link of image http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png

and the link i an parsing data from

http://free.worldweatheronline.com/feed/weather.ashx?q=peshawar,pakistan&format=xml&num_of_days=5&key=eab9f57359164426132301

Upvotes: 0

Views: 781

Answers (1)

Visruth
Visruth

Reputation: 3450

Here is the code to make a buffered image from the url.

try {
    URL url = new URL("http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png");
    BufferedImage bufferedImage = ImageIO.read(url);
    ImageIO.write(bufferedImage, "png", new FileOutputStream("/home/visruth/OutputImage.png"));// A file named OutputImage.png will be created in the location /home/visruth/
    } catch(Exception e) {
        e.printStackTrace();
    }

Upvotes: 1

Related Questions