HttpURLConnection响应的JSON 数据部全是怎么会事?在线等!!!!!

hewei5894 2012-02-28 07:46:39
代码是这样的:
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){}
用浏览器 返回的数据就是正常的、






...全文
180 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
搬运工木木 2012-02-28
  • 打赏
  • 举报
回复
String text2
while( (text2= br.readLine())!=null){
text = text +text2;

}
System.out.println(text);

实际上text一般是用stringbuffer或 stringbuilder的
hewei5894 2012-02-28
  • 打赏
  • 举报
回复
是我打印出来的内容 不全, 只有部分

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧