java properties
With properties in java how could I check if the value of the property is equal to something example if the property quitonload is equal to true then the p开发者_如何学Crogram will exit on start
Or if you're using a Properties file you can do this:
Properties p = new Properties()
p.load(new FileInputStream(args[0]))
if (p.getProperty("quitonload").equals("true")) {
System.out.println("quitonload is true");
System.exit(1);
}
System.out.println("quitonload is false");
Check the documentation on the Properties file if you have any doubts on the file format.
Do you mean something like:
if (System.getProperty("quitonload", "false").equals("true")) {
System.exit(1);
}
Note the quotation marks; system properties are always strings.
Properties are key/value pairs, each represented by a String
if (myPropertiesObj.getProperty("quitonload").equalsIgnoreCase("true"))
{
...
}
精彩评论