Here you can find the source of downloadUrl(String urlString)
private static InputStream downloadUrl(String urlString) throws IOException
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; public class Main { private static InputStream downloadUrl(String urlString) throws IOException { URL url = new URL(urlString); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(10000 /* milliseconds */); conn.setConnectTimeout(15000 /* milliseconds */); conn.setRequestMethod("GET"); conn.setDoInput(true);/*from ww w . ja va 2s .c o m*/ // Starts the query conn.connect(); InputStream stream = conn.getInputStream(); return stream; } }