Java Utililty Methods Is Directory Valid

List of utility methods to do Is Directory Valid

Description

The list of methods to do Is Directory Valid are organized into topic(s).

Method

booleanisValidDir(String dirName, boolean allowMissing)
is Valid Dir
if (dirName == null || dirName.trim().isEmpty()) {
    return false;
dirName = dirName.trim();
File dir = new File(dirName);
return dir.isDirectory() || (allowMissing && !dir.exists());
booleanisValidDir(String dirPath, boolean createDir)
is Valid Dir
try {
    File dir = new File(dirPath);
    if (createDir)
        dir.mkdirs();
    return dir.isDirectory();
} catch (Exception e) {
    return false;
booleanisValidDirectory(File directory)
is Valid Directory
if ((directory == null) || (directory.isHidden()) || (!directory.isDirectory())) {
    return false;
return true;
booleanisValidDirectory(File directory)
is Valid Directory
if (directory != null && directory.exists() && directory.canRead()) {
    File[] listOfFiles = directory.listFiles();
    if (listOfFiles.length != 0) {
        return true;
return false;
booleanisValidDirectory(File f)
Indicates if the given file is a valid directory.
return f.exists() && f.isDirectory() && f.canRead();
booleanisValidDirectory(final File folder)
Validates if folder is not null, exists and is a directory.
return ((null != folder) && (folder.exists()) && (folder.isDirectory()));
booleanisValidDirectory(String filePath)
is Valid Directory
if (filePath == null)
    return false;
File f = new File(filePath);
return f.exists() && f.isDirectory();
booleanisValidDirectory(String name)
Checks whether a given directory contains valid images for classification
File f = new File(name);
for (String file : f.list()) {
    if (!isImage(file, false)) {
        System.out.println("Error: Directory contains non-image file:\n" + file.toString());
        return false;
return true;
...
booleanisValidDirectory(String path)
A simple check that the directory path is a valid one for the current OS.
File file = new File(path);
try {
    file.getCanonicalPath();
    return true;
} catch (IOException e) {
    return false;