0

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

和链接我解析数据

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

4

1 回答 1

1

这是从 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();
    }
于 2013-01-28T16:22:54.033 回答