如何从url SAX解析中解析图像

时间:2013-01-28 16:10:56

标签: java xml image saxparser

如何从xml文件url内部链接解析图像。当我解析数据时,它会向我显示除了显示图像之外的链接。这是图像http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png

的链接

和链接i解析数据来自

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

1 个答案:

答案 0 :(得分:1)

以下是从网址制作缓冲图片的代码。

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();
    }