- 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
- package com.utilitySample;
- import org.apache.commons.lang.StringUtils;
- public class StringUtility {
- public static void main(String[] args) {
- System.out.println(StringUtils.isNotEmpty(null));
- System.out.println(StringUtils.isNotEmpty(""));
- System.out.println(StringUtils.isNotEmpty(" "));
- System.out.println(StringUtils.isNotEmpty("vel"));
- System.out.println(StringUtils.isNotEmpty(" vel "));
- }
- }
Output :
false
false
true
true
true
No comments:
Post a Comment