Java URI Create createConnection(final String uri, final String authValue)

Here you can find the source of createConnection(final String uri, final String authValue)

Description

create Connection

License

Apache License

Declaration

public static HttpURLConnection createConnection(final String uri, final String authValue) throws Exception 

Method Source Code


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

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

public class Main {
    public static HttpURLConnection createConnection(final String uri, final String authValue) throws Exception {
        final URL url = new URL(uri);
        final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setConnectTimeout(0);
        connection.setReadTimeout(0);/*from  ww  w  .j  av  a  2  s . c om*/
        connection.setRequestMethod("GET");

        connection.setRequestProperty("Authorization", authValue);

        connection.setDoOutput(true);

        return connection;
    }
}

Related

  1. convertToURI(String uriOrPath)
  2. convertToURI(String uriString, Map aliasMap)
  3. convertToURI(String value)
  4. create(final String uri)
  5. createAbsoluteURI(URI base, String uri)
  6. createDatastream(String registrationUri, String APIKey, String xmlDescription)
  7. createDefaultName(final String uri)
  8. createExtensionUri(final String ext)
  9. createURI()