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

booleancheckDir(final String dirName)
Checks to see if the given directory name corresponds to a directory that exists and can be read.
return checkDir(new File(dirName));
booleancheckDir(final String name)
Check input directory integrity.
return checkDir(new File(name));
booleancheckDir(String dir)
check Dir
File d = new File(dir);
boolean ret = d.exists();
if (ret && d.isFile())
    throw new RuntimeException("wrong directory:" + dir);
if (!ret) {
    d.mkdirs();
return ret;
...
booleancheckDir(String dir, boolean mustWrite)
check Dir
File file = new File(dir);
if (!file.exists())
    throw new IOException("Konnte Verzeichnis " + dir + " nicht finden!");
if (!file.isDirectory())
    throw new IOException(dir + " ist kein Verzeichnis!");
if (!file.canRead())
    throw new IOException("Verzeichnis " + dir + " ist nicht lesbar!");
if (mustWrite && !file.canWrite())
...
StringcheckDir(String directory)
Checks the given directory for its suffix, ('/' and '\', depending on the detected OS.
switch (detectOS()) {
case OTHER:
    System.err.println("[FileUtil : checkDir] Detected OS is not supported.");
    return null;
default:
    if (!directory.endsWith(File.separator)) {
        directory += File.separator;
    return directory;
booleancheckDir(String dirName)
check Dir
File stats = new File(dirName);
if (stats.exists()) {
    return true;
} else {
    if (stats.mkdir()) {
        return true;
    } else {
        return false;
...
FilecheckDir(String name)
Check if dir exists
File file = new File(name);
if (!(file.exists() && file.isDirectory())) {
    String msg = "No such directory: " + name;
    throw new IllegalArgumentException(msg);
return file;
voidcheckDir(String path)
check Dir
File file = new File(path);
if (!file.exists()) {
    if (!file.mkdirs())
        throw new RuntimeException(String.format("directory %s not create", path));
voidcheckDir(String path)
check Dir
File dist = new File(path);
if (dist.exists()) {
    if (!dist.isDirectory()) {
        dist.renameTo(new File(dist.getPath() + ".swp." + System.currentTimeMillis()));
        dist.mkdir();
} else {
    dist.mkdir();
...
voidcheckDir(String pDir)
check Dir
File lDir = new File(pDir);
if (!lDir.exists()) {
    if (!lDir.mkdirs()) {
        throw new Exception("Can not create backup dir: " + pDir);
if (!lDir.isDirectory()) {
    throw new Exception("File exists with name of backup dir: " + pDir);
...