Here you can find the source of getRequest(URL url, int timeout)
public static HttpURLConnection getRequest(URL url, int timeout) 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 { public static final int DEFAULT_HTTP_TIMEOUT = 60000; public static HttpURLConnection getRequest(URL url, int timeout) throws IOException { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setConnectTimeout(timeout); conn.setReadTimeout(timeout);/*from w w w . java 2s . c om*/ return conn; } public static HttpURLConnection getRequest(URL url) throws IOException { return getRequest(url, DEFAULT_HTTP_TIMEOUT); } }