`
mizhao1984
  • 浏览: 88358 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

java下载web图片

阅读更多

String url = "http://www.google.com.hk/logos/2010/stevenson10-hp.jpg";

  HttpClient client = new HttpClient();
  GetMethod get = new GetMethod(url);
  try {
   client.executeMethod(get);
   File storeFile = new File("d:/1.jpg");
   FileOutputStream fileOutputStream = new FileOutputStream(storeFile);
   FileOutputStream output = fileOutputStream;
   output.write(get.getResponseBody());
   output.close();
  } catch (HttpException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics