code: public static URLConnection prepareURLConnection(String url, int timeout) throws IOException {
  		URLConnection connection = new URL(url).openConnection();
  		connection.setReadTimeout(timeout);
  		connection.setConnectTimeout(timeout);
  		return connection;
  	}
docs: Prepare {@link URLConnection} with customised timeouts.
  
  @param url The URL
  @param timeout The timeout in millis for both the connection timeout and
  the response read timeout. Note that the total timeout is effectively two
  times the given timeout.
  
  <p>
  Example of code.      <code>
  UrlConnection conn = prepareURLConnection("http://www.google.com/", 20000);
  conn.connect();
  conn.getInputStream();
  </code>
  <p>
  
  <bold>NB. User should execute connect() method before getting input
  stream.</bold>
  @return
  @throws IOException
  @author Jacek Grzebyta