Ejemplo n.º 1
0
 /**
  * 根据一个文件路径建立一个输入流
  *
  * @param file 文件
  * @return 输入流
  */
 public static InputStream fileIn(File file) {
   try {
     return buff(Streams._input(file));
   } catch (IOException e) {
     throw Lang.wrapThrow(e);
   }
 }
Ejemplo n.º 2
0
  /**
   * 根据一个文件路径建立一个输入流
   *
   * @param path 文件路径
   * @return 输入流
   */
  public static InputStream fileIn(String path) {
    InputStream ins = Files.findFileAsStream(path);
    if (null == ins) {
      File f = Files.findFile(path);
      if (null != f)
        try {
          ins = Streams._input(f);
        } catch (IOException e) {
        }
    }
    if (null == ins) {
      // TODO 考虑一下,应该抛异常呢?还是返回null呢?

      throw new RuntimeException(new FileNotFoundException(path));
      // return null;
    }
    return buff(ins);
  }