Java Directory Exist Check checkDirExists(File dir)

Here you can find the source of checkDirExists(File dir)

Description

check Dir Exists

License

BSD License

Declaration

public static boolean checkDirExists(File dir) 

Method Source Code

//package com.java2s;
/**//  w  w w  .j av a2  s  .c o  m
 * Copyright (c) 2007-2010, Fintan Fairmichael, University College Dublin under the BSD licence.
 * See LICENCE.TXT for details.
 */

import java.io.File;

public class Main {
    public static boolean checkDirExists(File dir) {
        if (dir.isDirectory()) {
            return true;
        } else {
            return dir.mkdirs();
        }
    }

    public static boolean checkDirExists(String dirPath) {
        return checkDirExists(new File(dirPath));

    }
}

Related

  1. checkDirectory(String name, boolean createIfNonExistent)
  2. checkDirectoryExists(String path)
  3. checkDirExist(String path)
  4. checkDirExistence(String dir)
  5. checkDirExistenceOrCreateMissingParts(final String dirPath)
  6. checkDirExists(String dir)
  7. CheckDirExists(String dir, String name)