Here you can find the source of getURLConnection(String uri)
public static URLConnection getURLConnection(String uri) throws MalformedURLException, IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; public class Main { public static URLConnection getURLConnection(String uri) throws MalformedURLException, IOException { URLConnection urlConn = new URL(uri).openConnection(); urlConn.setConnectTimeout(120000); urlConn.setReadTimeout(120000);// www.j ava 2s.c o m urlConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)"); return urlConn; } }