Java HttpURLConnection Create getHttpConnection(String urlStr, String charSet, Map props)

Here you can find the source of getHttpConnection(String urlStr, String charSet, Map props)

Description

get Http Connection

License

Apache License

Declaration

public static HttpURLConnection getHttpConnection(String urlStr, String charSet, Map<String, String> props)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.net.HttpURLConnection;
import java.net.URL;

import java.util.Iterator;
import java.util.Map;

public class Main {
    public static HttpURLConnection getHttpConnection(String urlStr, String charSet, Map<String, String> props)
            throws IOException {
        URL url = new URL(urlStr);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        for (Iterator iterator = props.keySet().iterator(); iterator.hasNext();) {
            String k = (String) iterator.next();
            connection.addRequestProperty(k, props.get(k));
        }//from www  . j ava 2  s  .  c  om

        connection.setRequestMethod("GET");
        return connection;

    }
}

Related

  1. createHttpURLConnection(String urlString, int timeout)
  2. createHttpURLGetConnection(String url, int timeout)
  3. getHttpConnection(Proxy prx, URL u, int millis)
  4. getHttpConnection(String urlStr, Proxy proxy)
  5. getHTTPConnection(String urlString)
  6. getHttpConnection(URL url)
  7. getHttpConnection(URL url, int expectedResponseCode, int connectionTimeout)
  8. getHttpURLConnection(@Nonnull String urlStr)