Here you can find the source of getHttpURLConnectionByGET(String resourceURL)
Parameter | Description |
---|---|
resourceURL | The resource URL. |
Parameter | Description |
---|---|
IOException | an exception |
private static HttpURLConnection getHttpURLConnectionByGET(String resourceURL) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class Main { /**/*from w w w . j av a 2 s. com*/ * Get an object of HttpURLConnection. * * @param resourceURL * The resource URL. * @return * @throws IOException */ private static HttpURLConnection getHttpURLConnectionByGET(String resourceURL) throws IOException { HttpURLConnection conn = null; if (null != resourceURL && !"".equals(resourceURL.trim())) { URL url = new URL(resourceURL); conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(5000); conn.setRequestMethod("GET"); } return conn; } }