日期:2014-05-17 浏览次数:20693 次
public static String getResponseData(String url) throws Exception{
URL dataUrl = null;
String data = null;
try {
dataUrl = new URL(url);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
HttpURLConnection con = null;
try {
con = (HttpURLConnection) dataUrl.openConnection();
} catch (IOException e) {
e.printStackTrace();
}
con.setRequestMethod("GET");
con.setRequestProperty("Proxy-Connection", "Keep-Alive");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Charset", "utf-8");
con.setDoOutput(true);
con.setDoInput(true);
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = "";
String result = "";
while(null != (line=br.readLine())){
result += line;
}
return result;
}