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;
}
}
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;
}
}