Java Utililty Methods Directory Check

List of utility methods to do Directory Check

Description

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

Method

voidcheckDirectory(final String dir, final boolean create, final String errorDirName)
Check that a directory is valid.
try {
    checkDirectory(dir, create);
} catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(errorDirName + ": " + e.getMessage());
booleancheckDirectory(String value)
check Directory
boolean isWriteable = false;
File file = new File(value);
if (file.isDirectory() && file.canWrite()) {
    System.out.println(" \n:Able to write to the directory: " + file.getName());
    isWriteable = true;
} else {
    System.out.println(" \n:Cannot write to the directory " + value);
return isWriteable;
intcheckDirectoryArray(String[] names)
Checks a array of names for non existent or non directory entries and nulls them out.
int count = 0;
for (int i = 0; i < names.length; i++) {
    if (names[i] != null) {
        File dir = new File(names[i]);
        if (dir.exists() && dir.isDirectory()) {
            count++;
        } else {
            names[i] = null;
...
booleancheckDirectoryInWorkspace(String directoryName)
Check whether there is a directory existing in present workspace, with the given name.
boolean retVal = false;
File file = null;
try {
    file = new File(getWorkspacePath() + directoryName);
} catch (Exception exp) {
if ((file != null) && (file.exists()) && (file.isDirectory())) {
    retVal = true;
...
FilecheckDirPath(final String path)
check Dir Path
final File dir = new File(path);
if (!dir.exists()) {
    throw new IOException("Directory does not exist: " + path);
if (!dir.isDirectory()) {
    throw new IOException("Path does not point to a directory: " + path);
return dir;
...
voidcheckDirs(File f)
Make parent directories of the given file if no existing.
if (!f.getParentFile().exists()) {
    f.getParentFile().mkdirs();
voidcheckDirs(String dir)
check Dirs
File file = new File(dir);
if (!file.exists()) {
    file.mkdirs();
FilecheckDirs(String dirName)
Check if dir exists.
File dir = new File(dirName);
if (!dir.exists()) {
    dir.mkdirs();
return dir;