import java.io.IOException;
import java.util.Properties;
public class PropertyUtil {
public static void main(String[] args) {
Properties properties = new Properties();
try {
properties.load(PropertyUtil.class.getClassLoader().getResourceAsStream("LYZ.properties"));
String username = properties.getProperty("username");
System.out.println(username);
} catch (IOException e) {
System.out.println("LYZ.properties");
}
}
}
Exception in thread "main" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:434)
at java.util.Properties.load0(Properties.java:353)
at java.util.Properties.load(Properties.java:341)
at com.test.PropertyUtil.main(PropertyUtil.java:10)
:
properties.load(PropertyUtil.class.getClassLoader().getResourceAsStream("LYZ.properties"));