xifeng91
xifeng91
2017-10-23 11:14

https的图片通过java的URL类下载不了,报451错误

  • 图片
  • java
  • url

图片地址如下:https://swmedia-4cd6.kxcdn.com/media/catalogue/Aruba/Postage-stamps/A-s.jpg

每当执行下面的语句,到InputStream is = conn.getInputStream();的时候就会报如下错误:java.io.IOException: Server returned HTTP response code: 451 for URL

代码如下:
URL url = new URL(src);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.setRequestMethod("GET");

        InputStream is = conn.getInputStream();
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换