Java tutorial
//package com.java2s; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; public class Main { /** * Get image from newwork * @param path The path of image * @return InputStream * @throws Exception */ public static InputStream getImageStream(String path) throws Exception { URL url = new URL(path); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(5 * 1000); conn.setRequestMethod("GET"); if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { return conn.getInputStream(); } return null; } }