String emptyString = new String(); result = StringUtils.defaultIfEmpty(emptyString, "default"); System.out.println(result); String nullString = null; result = StringUtils.defaultIfEmpty(nullString, "default"); System.out.println(result);