Properties properties=new Properties(); properties.load(PropertiesMain.class.getClassLoader().getResourceAsStream("setting.properties")); System.out.println(properties.getProperty("a"));
你为啥要这个
getClassLoader()
PropertiesMain.class.getResourceAsStream("setting.properties")
我也不清楚,我这样就会找不到源文件,报空指针。PropertiesMain.class.getResourceAsStream("setting.properties")
Sign in to make a reply
Loading...