Java HttpURLConnection Open openConnection(URL url, Proxy proxy)

Here you can find the source of openConnection(URL url, Proxy proxy)

Description

open Connection

License

Mozilla Public License

Declaration

static HttpURLConnection openConnection(URL url, Proxy proxy) throws IOException 

Method Source Code


//package com.java2s;
/*/*from   w  ww.  j a  v a  2s. c o m*/
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import java.io.*;
import java.net.HttpURLConnection;

import java.net.Proxy;
import java.net.URL;

public class Main {
    static HttpURLConnection openConnection(URL url, Proxy proxy) throws IOException {
        HttpURLConnection result = (HttpURLConnection) url.openConnection(proxy);
        result.setConnectTimeout(15000);
        result.setReadTimeout(15000);
        result.setUseCaches(false);
        return result;
    }
}

Related

  1. getConnectionCharset(HttpURLConnection connection)
  2. getConnectionStream(HttpURLConnection con)
  3. openConnection(final String urlString)
  4. openConnection(final URL url, final String requestMethod)
  5. openConnection(String url, String method, String contentType, String ssic)
  6. openConnectionCheckRedirects(URLConnection c)