I'm trying to adapt a code which uses String.isBlank(text)
. This method was introduced in Java 11, but my current project uses Java 8 and I don't want to upgrade. Is there anywhere the source code of the isBlank
method or how can I replace it?
I tried make a method but I'm not sure what check should I put in there:
/**
* @param text - the text to check
* @return {@code true} if {@code text} is empty or contains only white space codepoints
*/
public static final boolean isBlank(final String text)
{
if (text == null || text.isEmpty())
{
return true;
}
for (final char c : text.toCharArray())
{
//Check here
}
return false;
}