使用服务器上的url路径上传图片

时间:2013-12-18 11:22:24

标签: java

我无法使用以下代码在服务器上上传图片。得到例外:can't read input stream with URL

BufferedImage image = null;
    try {

        URL url = new URL("http://www.mkyong.com/image/mypic.jpg");
        image = ImageIO.read(url);

        ImageIO.write(image, "jpg",new File("C:\\out.jpg"));
        ImageIO.write(image, "gif",new File("C:\\out.gif"));
        ImageIO.write(image, "png",new File("C:\\out.png"));

    } catch (IOException e) {
           e.printStackTrace();
    }

0 个答案:

没有答案