NullPointerException when reading a properties file in Java

前端 未结 11 1368
我在风中等你
我在风中等你 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:17

    I had the same problem and I have resolved by doing the following

    1. File file = new File("resources.properties");
    2. System.out.println(file.getAbsolutePath());

    and then put "resources.properties" file under that path.

提交回复
热议问题