Here you can find the source of openInputStream(File file)
Parameter | Description |
---|---|
file | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static FileInputStream openInputStream(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { /**/*from w w w .j ava 2 s. c om*/ * Open InputStream for a file. * @param file * @return * @throws IOException * @since 2012-7-24 */ public static FileInputStream openInputStream(File file) throws IOException { if (file.exists()) { if (file.isDirectory()) { throw new IOException("File '" + file + "' exists but is a directory"); } if (!file.canRead()) { throw new IOException("File '" + file + "' cannot be read"); } else { return new FileInputStream(file); } } else { throw new FileNotFoundException("File '" + file + "' does not exist"); } } }