Here you can find the source of getConnection(String url)
public static HttpURLConnection getConnection(String url)
//package com.java2s; //License from project: Open Source License import java.net.HttpURLConnection; import java.net.URL; public class Main { public static HttpURLConnection getConnection(String url) { try {// w ww . jav a 2 s . c om return (HttpURLConnection) new URL( url.startsWith("http://") ? url : "http://" + url) .openConnection(); } catch (Exception e) { } return null; } }