80,361
社区成员
发帖
与我相关
我的任务
分享
public static InputStream getInputStreamFromUrl(String urlstr){
try {
InputStream is = null;
HttpURLConnection conn = null;
System.out.println("urlstr:"+urlstr);
URL url = new URL(urlstr);
conn = (HttpURLConnection) url.openConnection();
if (conn.getResponseCode() == 200) {
is = conn.getInputStream();
return is;
}
} catch (Exception e) {
System.out.println(e.toString());
}
return null;
}