80,351
社区成员
发帖
与我相关
我的任务
分享
StringBuilder stringBuilder=new StringBuilder();
try {
url=new URL("https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg?uin=0¬ice=0&platform=h5&needNewCode=1&tpl=3&page=detail&type=top&topid=27" );
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection httpURLConnection=(HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty("content-type","text/html");
InputStream inputStream= httpURLConnection.getInputStream();
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(inputStream));
char[] chars=new char[1024];
int i=0;
while ((bufferedReader.read(chars))!=-1)
{
String sd=new String(chars);
Log.i("tests","第"+i+"次添加:"+sd);
stringBuilder.append(sd);
i++;
}
Log.i("tests","stringbulider: "+stringBuilder.toString());
Message message=new Message();
message.what=1;
message.obj=stringBuilder.toString();
my.sendMessage(message);
bufferedReader.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}