Java Directory Check checkDir(final String dirName)

Here you can find the source of checkDir(final String dirName)

Description

Checks to see if the given directory name corresponds to a directory that exists and can be read.

License

Open Source License

Parameter

Parameter Description
dirName a file name to test.

Return

true iff dirName exists, is a directory and can be read.

Declaration

public static boolean checkDir(final String dirName) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    /**/*ww  w.j ava 2s  .com*/
     * Checks to see if the given directory name corresponds to a directory that
     * exists and can be read.
     *
     * @param dirName a file name to test.
     * @return true iff dirName exists, is a directory and can be read.
     */
    public static boolean checkDir(final String dirName) {
        return checkDir(new File(dirName));
    }

    /**
     * Checks to see if the given file exists and is a directory.
     *
     * @param f a File to test.
     * @return true iff f exists and is a directory.
     */
    public static boolean checkDir(final File f) {
        return f.exists() && f.isDirectory();
    }
}

Related

  1. checkDir(final String name)
  2. checkDir(String dir)
  3. checkDir(String dir, boolean mustWrite)
  4. checkDir(String directory)