Code example for URL

Methods: openConnection

0
     */ 
    public static HttpURLConnection buildHttpUrlConnection(String urlString)
            throws MalformedURLException, IOException { 
        AndroidUtils.disableConnectionReuseIfNecessary(); 
 
        URL url = new URL(urlString);
 
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setReadTimeout(10000 /* milliseconds */);
        conn.setConnectTimeout(15000 /* milliseconds */);
        conn.setDoInput(true);
        conn.setRequestMethod("GET");
        return conn;
    } 
 
    /** 
     * Prior to Android 2.2 (Froyo), {@link HttpURLConnection} had some 
     * frustrating bugs. In particular, calling close() on a readable 
     * InputStream could poison the connection pool. Work around this by 
     * disabling connection pooling. 
     */