碰到一个properties的资源文件,读取报空指针,什么原因?
我使用下面2中方式读取,都是空指针。
Properties pro
= new Properties();
pro.load(Demo.class.getResourceAsStream("/project/db.properties"));
pro.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("project/db.properties"));
Exception:
Exception in thread "main" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at project.HashMap.Demo.main(Demo.java:23)