tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Commons Lang3 > Booleans > Boolean to String

Boolean to String 

Apache Commons Lang 3.0 is a java library with lot of utilities and reusable components. This requires the library commons-lang3-3.0.1.jar to be in classpath. The following example shows converting boolean to string.

File Name  :  
com/bethecoder/tutorials/commons_lang/tests/booleans/BooleanToStringTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.commons_lang.tests.booleans;

import org.apache.commons.lang3.BooleanUtils;

public class BooleanToStringTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    System.out.println(BooleanUtils.toStringOnOff(null));
    System.out.println(BooleanUtils.toStringOnOff(Boolean.TRUE));
    System.out.println(BooleanUtils.toStringOnOff(Boolean.FALSE));
    
    System.out.println(BooleanUtils.toStringTrueFalse(null));
    System.out.println(BooleanUtils.toStringTrueFalse(Boolean.TRUE));
    System.out.println(BooleanUtils.toStringTrueFalse(Boolean.FALSE));
    
    System.out.println(BooleanUtils.toStringYesNo(null));
    System.out.println(BooleanUtils.toStringYesNo(Boolean.TRUE));
    System.out.println(BooleanUtils.toStringYesNo(Boolean.FALSE));
  }

}
   

It gives the following output,
null
on
off

null
true
false

null
yes
no


                    Print

   



Books Recommendation

 
 
bl  br