StringUtils.isNotEmpty

  • StringUtils.isNotEmpty("variable") function is used to check whether the string length is not 0 or null.
  • This function is null safe.
  • You can use this method with the help of commons-lang-2.6.jar.
  • You can download this jar by using the below link


  1.  package com.utilitySample;
  2.  import org.apache.commons.lang.StringUtils;

  3.  public class StringUtility {
  4. public static void main(String[] args) {
  5.                  System.out.println(StringUtils.isNotEmpty(null));   
  6. System.out.println(StringUtils.isNotEmpty(""));      
  7. System.out.println(StringUtils.isNotEmpty(" "));     
  8. System.out.println(StringUtils.isNotEmpty("vel"));    
  9. System.out.println(StringUtils.isNotEmpty("  vel  "));
  10.    }
  11.  }

 Output : 
   false
   false
   true
   true
   true

No comments:

Post a Comment