Code example for URL

Methods: openConnection

0
    } 
 
	private HttpURLConnection createConnection(String url) {
        URL newUrl = null;
		try { 
            newUrl = new URL(url);
		} catch (MalformedURLException e) {
			return null; 
		} 
 
        HttpURLConnection con = null;
        try { 
            con = (HttpURLConnection) newUrl.openConnection();
        } catch (IOException e) {
            return null; 
        } 
        con.setReadTimeout(60000);
        con.setConnectTimeout(60000);
        con.addRequestProperty("Expect", "100-continue");
        con.addRequestProperty("Authorization",
                               "Basic "+Base64.encodeToString((this.username + ":" + this.password).getBytes(),