1、getResourceAsStream(String path)读取的文件路径是与工程相关的,例如工程中的某个路径下的文件(/demo/static/img/logo.png)。
2、如果文件不在工程目录下,应该采用以下方式:
File file = new File(logoPath); InputStream is= null; try{ is = new FileInputStream(file); }catch (Exception e){ e.printStackTrace(); }
3、本篇文章主要是记录getResourceAsStream(String path)的用法,如有错误,请纠正。