Java HttpURLConnection Open getConnection(String url)

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

Description

get Connection

License

Open Source License

Declaration

public static HttpURLConnection getConnection(String url) 

Method Source Code

//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;
    }
}

Related

  1. getConnection(String urlStr, boolean useProxy)
  2. getConnection(URL url)
  3. getConnectionCharset(HttpURLConnection connection)
  4. getConnectionStream(HttpURLConnection con)