NullPointerException when reading a properties file in Java

前端 未结 11 1409
我在风中等你
我在风中等你 2020-12-09 17:05

I am using the following code to read a properties file:

Properties pro = new Properties();
InputStream is = Thread.currentThread().getContextClassLoader().         


        
11条回答
  •  渐次进展
    2020-12-09 17:15

    In my situatioan I get NullPointerException in this code

    LogManager.getLogManager()
          .readConfiguration(MyClass.class.getResourceAsStream("config/logging.properties"));
    

    I changed

    LogManager.getLogManager().readConfiguration(AzLotteryTerm.class.getClassLoader().getResourceAsStream("config/logging.properties"));
    

    and now works ok!

提交回复
热议问题