HttpURLConnection 请求
private void init() {
try {
URL url = new URL(uri);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
in=conn.getInputStream();
BufferedReader buff=new BufferedReader(new InputStreamReader(in));
while((str=buff.readLine())!=null){
s+=str;
}
Message msg=Message.obtain();
msg.obj=s;
h.sendMessage(msg);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}