Java Directory Check checkDir(String name)

Here you can find the source of checkDir(String name)

Description

Check if dir exists

License

Lingpipe license

Parameter

Parameter Description
name directory name

Exception

Parameter Description
IOException an exception

Declaration

public static File checkDir(String name) throws IOException 

Method Source Code


//package com.java2s;
/*//from  ww w  .  ja v a2s .co m
 * LingPipe v. 2.0
 * Copyright (C) 2003-5 Alias-i
 *
 * This program is licensed under the Alias-i Royalty Free License
 * Version 1 WITHOUT ANY WARRANTY, without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the Alias-i
 * Royalty Free License Version 1 for more details.
 *
 * You should have received a copy of the Alias-i Royalty Free License
 * Version 1 along with this program; if not, visit
 * http://www.alias-i.com/lingpipe/licenseV1.txt or contact
 * Alias-i, Inc. at 181 North 11th Street, Suite 401, Brooklyn, NY 11211,
 * +1 (718) 290-9170.
 */

import java.io.File;
import java.io.IOException;
import java.io.IOException;

public class Main {
    /**
     * Check if dir exists
     *
     * @param name directory name
     * @throws IOException
     */
    public static File checkDir(String name) throws IOException {
        File file = new File(name);
        if (!(file.exists() && file.isDirectory())) {
            String msg = "No such directory: " + name;
            throw new IllegalArgumentException(msg);
        }
        return file;
    }
}

Related

  1. checkDir(final String name)
  2. checkDir(String dir)
  3. checkDir(String dir, boolean mustWrite)
  4. checkDir(String directory)
  5. checkDir(String dirName)
  6. checkDir(String path)
  7. checkDir(String path)
  8. checkDir(String pDir)
  9. checkDirAndCreate(File dir)