Code example for DefaultHttpClient

Methods: execute

	public static InputStream getInputStreamFromUrl(String url)
			throws ClientProtocolException, IOException { 
		HttpGet request = new HttpGet(url);
		DefaultHttpClient client = new DefaultHttpClient(getTimeoutHttpParams());
		HttpResponse response = client.execute(request);
		int statusCode = response.getStatusLine().getStatusCode();
		if (statusCode != 200) {
			Log.e(TAG, "Failed to get stream for: " + url);
			throw new IOException("Failed to get stream for: " + url);
		return response.getEntity().getContent();
	public static String fetchContent(String url)
			throws ClientProtocolException, IOException { 
		InputStream input = getInputStreamFromUrl(url);
		try { 
			int c;
Stop searching for code, let great code find you!  Add Codota to your java IDE