Search code examples
javaintellij-ideaspring-tool-suite

IntelliJ IDEA - Get Cannot resolve method 'isBlank' in 'String' but works fine in STS


I recently moved my Java project from Spring Tools IDE to IntelliJ, but I'm getting an error that I'm not having in STS : "Cannot resolve method 'isBlank' in 'String' " Which is more, in Spring Tools the test is running successfully. I tried rebuild the pom file but still having the error.

The portion of code I'm using is this:

if (uploadedPDFName == null || uploadedPDFName.isBlank()) {
    //do something
}

I'm capturing file name in a string variable.


Solution

  • I think the problem is about your JDK version,if you have an old version like JDK 8 or JDK 7 ...you will have an error when using isBlank() because String::isBlank() was introduced in java 11. You Can check by typing :java --version in a terminal if you have an old version,you Can just use isEmpty().