I want to read a properties file test.properties, and show the value which is
defined in properties file in a lable. But I can't read the properties file
I have tried
property.load(ClassLoader.getSystemResourceAsStream("test.properties"));
property.load(this.getClass().getClassLoader().getResourceAsStream("test.properties"));
property.load(PackageResource.get(test.class,
"test.properties").getResourceStream().getInputStream());
property.load(((WebApplication)
Application.get()).getServletContext().getResourceAsStream("test.properties"));
But it always generate null point error
java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:365)
at java.util.Properties.load(Properties.java:293)
Then I tried to test reading in main method, and it works fine there.
public static void main(String[] args){
Properties property = new Properties();
try {
property.load(ClassLoader.getSystemResourceAsStream("test.properties"));
} catch (IOException e) {
e.printStackTrace(); }
System.out.println(property.getProperty("a key"));
}
Really can't understand why. Did I do something in wrong way? Thanks for any
help or sugestion.
--
View this message in context:
http://www.nabble.com/problem-when-reading-properties-file-tp17597421p17597421.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]