Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; public class Main { private static InputStream OpenHttpConnection(String strURL, Boolean cache) throws IOException { InputStream inputStream = null; try { URL url = new URL(strURL); URLConnection conn = url.openConnection(); conn.setUseCaches(cache); HttpURLConnection httpConn = (HttpURLConnection) conn; httpConn.setRequestMethod("GET"); httpConn.connect(); if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) inputStream = httpConn.getInputStream(); } catch (Exception ex) { } return inputStream; } }