Here you can find the source of getInputStream(File TheFile)
public static InputStream getInputStream(File TheFile)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**/*www .j a v a 2 s . com*/ * @param name non-null name of an existing readable file * @return non-null IpuptStream * @throws IllegalArgumentException on error */ public static InputStream getInputStream(String name) { File TheFile = new File(name); return getInputStream(TheFile); } public static InputStream getInputStream(File TheFile) { validateReadableFile(TheFile); try { InputStream in = new FileInputStream(TheFile); return (in); } catch (FileNotFoundException ex) { String Fullpath = TheFile.getAbsolutePath(); throw new IllegalStateException( "Requested File '" + Fullpath + "' does not exist - but has been tested - HUH???"); } } public static void validateReadableFile(File TheFile) { if (!TheFile.exists()) { String Fullpath = TheFile.getAbsolutePath(); throw new IllegalArgumentException("Requested File '" + Fullpath + "' does not exist"); } if (!TheFile.canRead()) { String Fullpath = TheFile.getAbsolutePath(); throw new IllegalArgumentException("Requested File '" + Fullpath + "' cannot be read"); } if (TheFile.isDirectory()) { String Fullpath = TheFile.getAbsolutePath(); throw new IllegalArgumentException("Requested File '" + Fullpath + "'is a directory"); } } }