FileInputStream

阅读更多
public static InputStream getInputStream(String filePath) {
  InputStream is =null;
  try {
   is = FileUtil.class.getClassLoader().getResourceAsStream(filePath);
  } catch (Exception ex) {
  
  }
  if (is==null) {
   try {
    is=ClassLoader.getSystemResourceAsStream(filePath);
   } catch (Exception ex) {
   }
  }
  if (is==null) {
  
   try {
    is = new FileInputStream(filePath);
   } catch (FileNotFoundException e) {
   }
  }
  return is;
}

你可能感兴趣的:(java)