I use the following code to check timing:
public static void main(String[] args) throws Exception {
String foo = "foo";
long start=System.currentTimeMillis();
if (StringUtils.isBlank(foo));
long end=System.currentTimeMillis();
System.out.println("isBlank="+(end-start));
start=System.currentTimeMillis();
if (foo!=null && !foo.isEmpty());
end=System.currentTimeMillis();
System.out.println("Sec="+(end-start));
}
The StringUtils.isBlank() method takes 3ms longer than a simple String.isEmpty() method. Which method should we use?