tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
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  :  kvenkatasudhakar@gmail.com
   
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


                    Print

   



Books Recommendation

 
 
bl  br