Here you can find the source of getInputStreamFile(String URLString)
Parameter | Description |
---|---|
URLString | The URI to the file resource |
Parameter | Description |
---|---|
Exception | an exception |
public static InputStream getInputStreamFile(String URLString) throws Exception
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.OutputStream; public class Main { /**/*from www . ja v a 2s .com*/ * Get the InputStream from a File * * @param URLString The URI to the file resource * @return The InputStream to read the file resource. Close this in calling code. * @throws Exception */ public static InputStream getInputStreamFile(String URLString) throws Exception { final String eLabel = "ResourceRequestUtils.getInputStreamFile: "; OutputStream os = null; try { File file = new File(URLString); if ((!file.exists()) || (!file.isFile())) { throw new Exception("File resource does not exist: " + URLString); } return new FileInputStream(file); } catch (Exception e) { throw new Exception(eLabel + e + " " + URLString); } finally { try { os.close(); } catch (Exception e) { } } } }