James Schmidt

Software engineering and architecture from the trenches

Follow me on GitHub

How to Check for Empty String in Java

on java

Not suprisingly most programming languages handle this check the same way. You have to check for null first to avoid a NullPointerException.

if (string == null || string.IsEmpty()) {

If you are using Spring just use StringUtils.isEmpty. Google’s Guava has Strings.isNullorEmpty. Or write your own.