日期:2014-05-20 浏览次数:20659 次
String reqUrl = "http://www.....";// 请求的网页网址(省略)
URL url = new URL(reqUrl);
HttpURLConnection url_conn = (HttpURLConnection)url.openConnection();
url_conn.setRequestMethod("GET");
url_conn.setConnectTimeout(HttpRequestProxy.connectTimeOut);//设置连接超时
url_conn.setReadTimeout(HttpRequestProxy.readTimeOut);//设置读取超时
InputStream in = url_conn.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in, "GBK"));
String tempLine = br.readLine();
StringBuffer temp = new StringBuffer();
while(tempLine != null){
temp.append(tempLine + "\n");
tempLine = br.readLine();
}
String responseContent = temp.toString();// 这就是返回的乱码字符串
br.close();
in.close();