Here you can find the source of getInputStream(String myUrl)
public static InputStream getInputStream(String myUrl) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static final int READ_TIMEOUT_MILLIS = 10000; public static final int CONNECTION_TIMEOUT_MILLIS = 15000; public static InputStream getInputStream(String myUrl) throws IOException { InputStream is = null;/*from www . j a v a 2 s . c om*/ URL url = new URL(myUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(READ_TIMEOUT_MILLIS /* milliseconds */); conn.setConnectTimeout(CONNECTION_TIMEOUT_MILLIS /* milliseconds */); conn.setRequestMethod("GET"); conn.setDoInput(true); // Starts the query conn.connect(); return conn.getInputStream(); } }