Tag: nullpointerexception输入

在Java中读取属性文件时出现NullPointerException

我使用以下代码来读取属性文件: Properties pro = new Properties(); InputStream is = Thread.currentThread().getContextClassLoader(). getResourceAsStream(“resources.properties”); pro.load(is); 当我执行代码时,我收到以下错误: Exception in thread “main” java.lang.NullPointerException at java.util.Properties$LineReader.readLine(Properties.java:418) at java.util.Properties.load0(Properties.java:337) at java.util.Properties.load(Properties.java:325) at com.ibm.rqm.integration.RQMUrlUtility.RQMRestClient.getResource(RQMRestClient.java:66) at com.ibm.rqm.integration.RQMUrlUtility.RQMRestClient.main(RQMRestClient.java:50) 为什么我得到NullPointerException ? 我应该在哪里保存resources.properties文件?