if(str != null && !str.isEmpty()) { /* do your stuffs here */ }
if(str != null && !str.isEmpty())
Be sure to use the parts of && in this order, because java will not proceed to evaluate the second part if the first part of && fails, thus ensuring you will not get a null pointer exception from str.isEmpty() if str is null.
if (myString == null || myString.equals(""))
throw new IllegalArgumentException("empty string");
/* You can use Apache Commons */
StringUtils.isEmpty(str)
/* which checks for empty strings and handles null gracefully. */
/* HINT */
/* the shorter and simler your code, the easier it is to test it */