如何把Word文档中的图片下载到服务器中指定的路径下面

如何把Word文档中的图片下载到服务器中指定的路径下面?

我的代码如下:

//按照按照指定的地址去下载图片同时保存在指定的文件夹中
public static void downloadPicturesAddress(String urlString, String filename) throws Exception {
    // 构造URL
    URL url = new URL(urlString);
    // 打开连接
    URLConnection con = url.openConnection();
    // 输入流
    InputStream is = con.getInputStream();
    // 1K的数据缓冲
    byte[] bs = new byte[1024];
    // 读取到的数据长度
    int len;
    // 输出的文件流
    OutputStream os = new FileOutputStream(filename);
    // 开始读取
    while ((len = is.read(bs)) != -1) {
      os.write(bs, 0, len);
    }
    // 完毕,关闭所有链接
    os.close();
    is.close();
    }

    这段代码给定指定的网站地址(http://img1.cache.netease.com/catchpic/7/79 /7911DF7F9E17E8E638349A27A882D9D0.jpg)可以下载,如果是word文件中的地址            (file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01 \clip_image001.png)则无法下载,
    很郁闷啊?

猜你喜欢

转载自dingjinhua.iteye.com/blog/1163497