StringUtils.isNotBlank

  • StringUtils.isNotBlank("vaiable") function return false for null,Empty and whitespace string.
  • Where as StringUtils.isNotEmpty("variable") function return true for whiteSpace string.
  • 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.isNotBlank(null));
  6. System.out.println(StringUtils.isNotBlank(""));
  7. System.out.println(StringUtils.isNotBlank(" "));
  8. System.out.println(StringUtils.isNotBlank("vel"));
  9. System.out.println(StringUtils.isNotBlank("  vel  "));
  10.    }
  11.  }

 Output : 
 false
 false
 false
 true
 true


No comments:

Post a Comment