Here you can find the source of openFileOrURL(String fileNameOrUrl)
public static InputStream openFileOrURL(String fileNameOrUrl) throws IOException
//package com.java2s; //License from project: BSD License import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; public class Main { public static InputStream openFileOrURL(String fileNameOrUrl) throws IOException { try {/*from ww w . j av a 2s . co m*/ URL url = new URL(fileNameOrUrl); return url.openStream(); } catch (MalformedURLException mfe) { InputStream str = new FileInputStream(fileNameOrUrl); return str; } } }