下载html源码
?public void getHtml() throws ClientProtocolException, IOException?
{?
? ? HttpClient httpClient = new DefaultHttpClient();?
? ? HttpContext localContext = new BasicHttpContext();?
? ? HttpGet httpGet = new HttpGet("http://www.spartanjava.com");?
? ? HttpResponse response = httpClient.execute(httpGet, localContext);?
? ? String result = "";?
?
? ? BufferedReader reader = new BufferedReader(?
? ? ? ? new InputStreamReader(?
? ? ? ? ? response.getEntity().getContent()?
? ? ? ? )?
? ? ? );?
?
? ? String line = null;?
? ? while ((line = reader.readLine()) != null){?
? ? ? result += line + "\n";?
? ? ? Toast.makeText(activity.this, line.toString(), Toast.LENGTH_LONG).show();?
?
? ? }?
?
}?