日期:2014-05-19  浏览次数:20603 次

HttpURLConnection响应的JSON 数据部全是怎么会事?在线等!!!!!
代码是这样的:
try{ 
String url= "http://m.qzone.qq.com/cgi-bin/new/msgb_output_page?uin=1234567&start=1&json=1&num=4"; 
URL login = new URL(url); 
HttpURLConnection conn =null; 

conn =(HttpURLConnection)login.openConnection();//openConnection();//打开链接 
HttpURLConnection.setFollowRedirects(true);
// conn.setRequestProperty( "username ", "username "); 
// conn.setRequestProperty( "password ", "userpwd ");

conn.setDoOutput(true);
conn.setRequestProperty("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows 2000)");
conn.setRequestMethod( "GET"); //
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String text ="";
while( null != br.readLine()){
text = text +br.readLine();
System.out.println(br.readLine());
}
}catch(Exception e){} 
用浏览器 返回的数据就是正常的、








------解决方案--------------------
String text2
while( (text2= br.readLine())!=null){
text = text +text2;

}
System.out.println(text);

实际上text一般是用stringbuffer或 stringbuilder的