Plain Java
public class ApacheCommonsTest {
public void print(String text) {
if (text != null && text.trim().length() != 0) {
System.out.println(text);
}
}
}
StringUtils
import org.apache.commons.lang3.StringUtils;
public class ApacheCommonsTest {
public void print(String text) {
if (!StringUtils.isBlank(text)) {
System.out.println(text);
}
}
}
StringUtils (static import)
import static org.apache.commons.lang3.StringUtils.isBlank;
public class ApacheCommonsTest {
public void print(String text) {
if (!isBlank(text)) {
System.out.println(text);
}
}
}