get Http URL Connection - Java Network

Java examples for Network:Http

Description

get Http URL Connection

Demo Code


//package com.java2s;

import java.io.IOException;

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

public class Main {
    public static void main(String[] argv) throws Exception {
        String strUrl = "java2s.com";
        System.out.println(getHttpURLConnection(strUrl));
    }//w w w .  j av  a  2 s . c o  m

    public static HttpURLConnection getHttpURLConnection(String strUrl)
            throws IOException {
        URL url = new URL(strUrl);
        HttpURLConnection httpURLConnection = (HttpURLConnection) url
                .openConnection();
        return httpURLConnection;
    }
}

Related Tutorials