Java: How to Convert a System Property In A Boolean

The method java.lang.Boolean.getBoolean("KEY") converts the value of the system property with the given key to a boolean:


//...
public static void main(String[] args) {
    boolean dryRun = Boolean.getBoolean("dry.run");
}

Since Java 1.0.2 the test is case insensitive :-).

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License