Java URLConnection Create createConnection(URL url)

Here you can find the source of createConnection(URL url)

Description

create Connection

License

Open Source License

Declaration

private static URLConnection createConnection(URL url) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.*;

import java.net.URL;
import java.net.URLConnection;

public class Main {
    private static URLConnection createConnection(URL url) throws IOException {
        URLConnection con = url.openConnection();
        con.addRequestProperty("Protocol", "HTTP/1.1");
        con.addRequestProperty("Connection", "keep-alive");
        con.addRequestProperty("Keep-Alive", "200");
        con.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1");
        return con;
    }/* w w  w  .j  ava 2s  .com*/
}

Related

  1. createConnection(final URL url, final String authValue)
  2. createConnection(String method, String destinationUrl)
  3. createConnection(String processorName, String baseUrl)
  4. createConnection(URL url)
  5. createConnection(URL url)
  6. createConnection(URL url, Proxy proxy)
  7. getURLConnection(String uri)