Utis类

来源:互联网 发布:山东临沂外包淘宝客服 编辑:程序博客网 时间:2024/06/07 07:42
public class NetUtils {
public static Reader getDataByGet(String path){
InputStreamReader isr = null;
try {
URL url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");

int code = conn.getResponseCode();
if(code == 200){
InputStream is = conn.getInputStream();
isr = new InputStreamReader(is);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return isr;
}
}
原创粉丝点击