Android URL Parse getStringFromUrl(String url)

Here you can find the source of getStringFromUrl(String url)

Description

get String From Url

Declaration

public static String getStringFromUrl(String url)
        throws ClientProtocolException, IOException 

Method Source Code

//package com.java2s;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

public class Main {

    public static String getStringFromUrl(String url)
            throws ClientProtocolException, IOException {
        HttpGet get = new HttpGet(url);
        HttpClient client = new DefaultHttpClient();
        HttpResponse response = client.execute(get);
        HttpEntity entity = response.getEntity();
        return EntityUtils.toString(entity, "UTF-8");
    }/*from  w  w  w.jav  a 2s  .c  o  m*/
}

Related

  1. getHost(String url)
  2. getNormalizedURLString(String url)
  3. getOrigin(String url)
  4. getParentUrl(String url)
  5. getRecentMediaUrl(String tag)
  6. getUrlContent(String urlStr)
  7. getUrlQueryParameters(final String url)
  8. checkStringIsUrl(String input)
  9. hostFromUrl(String url)