tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java > Core > Boolean > Read System boolean properties

Read System boolean properties 

This example shows reading a boolean system property.

File Name  :  
com/bethecoder/tutorials/core/bool/GetBoolean.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.core.bool;

public class GetBoolean {

  public static void main (String [] args) {
    
    /**
     * Boolean.getBoolean method reads the system property
     * and translates it into a boolean value.
     */
    boolean bool = Boolean.getBoolean("ENABLE_DEBUG_FLAG");
    System.out.println(bool);
    
    //Set the system property either through application
    //startup parameters (-DENABLE_DEBUG_FLAG=TruE) or System.setProperty
    System.setProperty("ENABLE_DEBUG_FLAG""TruE");
    
    bool = Boolean.getBoolean("ENABLE_DEBUG_FLAG");
    System.out.println(bool);
    
  }
}
   

It gives the following output,
false
true



 
  


  
bl  br