How to check if a folder exists?

Using java.nio.file.Files:

Path path = ...;

if (Files.exists(path)) {
    // ...
}

You can optionally pass this method LinkOption values:

if (Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {

There’s also a method notExists:

if (Files.notExists(path)) {

Leave a Comment