package helper;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class ReadConfigProperty {
public static void main (String[] args) {
InputStream input = ReadConfigProperty.class.getClassLoader().getResourceAsStream("resource/config.properties");
Properties prop = new Properties( );
try {
prop.load(input);
System.out.println("url :" + prop.getProperty("url"));
System.out.println("url:" + prop.getProperty("browser"));
System.out.println("url:" + prop.getProperty("Username"));
System.out.println("url :" + prop.getProperty("password"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
I am receiving below exception during running of ReadConfigProperty :
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 helper.ReadConfigProperty.main(ReadConfigProperty.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Process finished with exit code 1