Here you can find the source of getStreamWithTimeOut(String stringUrl, Integer timeOutInMilli)
public static URLConnection getStreamWithTimeOut(String stringUrl, Integer timeOutInMilli) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.net.URL; import java.net.URLConnection; public class Main { private static final Integer DEFAULT_TIME_OUT_IN_MILLI = 10000; public static URLConnection getStreamWithTimeOut(String stringUrl, Integer timeOutInMilli) throws IOException { URL url = new URL(stringUrl); URLConnection urlConnection = url.openConnection(); urlConnection.setReadTimeout(timeOutInMilli); urlConnection.setConnectTimeout(timeOutInMilli); return urlConnection; }/*from w ww.j a v a 2 s . c om*/ public static URLConnection getStreamWithTimeOut(String stringUrl) throws IOException { return getStreamWithTimeOut(stringUrl, DEFAULT_TIME_OUT_IN_MILLI); } }