Android examples for Network:HTTP Get
Get an object of HttpURLConnection.
//package com.java2s; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class Main { /**//from w ww . j av a 2 s .c o m * Get an object of HttpURLConnection. * * @param resourceURL * The resource URL. * @return * @throws IOException */ private static HttpURLConnection getHttpURLConnectionByGET( String resourceURL) throws IOException { HttpURLConnection conn = null; if (null != resourceURL && !"".equals(resourceURL.trim())) { URL url = new URL(resourceURL); conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(5000); conn.setRequestMethod("GET"); } return conn; } }