Java Is Legal File Path isLegalDir(final String dirname)

Here you can find the source of isLegalDir(final String dirname)

Description

Proves if the argument points to a existent directory (not file!).

License

Open Source License

Parameter

Parameter Description
dirname Path to a directory

Return

true if the path points to a directory, false if the directory does not exist or is a file.

Declaration

public static boolean isLegalDir(final String dirname) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2005, 2007 committers of openArchitectureWare and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   www  .j ava2  s.  c  om*/
 *     committers of openArchitectureWare - initial API and implementation
 *******************************************************************************/

import java.io.File;

public class Main {
    /**
     * Proves if the argument points to a existent directory (not file!).
     * 
     * @param dirname
     *            Path to a directory
     * @return <tt>true</tt> if the path points to a directory, <tt>false</tt>
     *         if the directory does not exist or is a file.
     */
    public static boolean isLegalDir(final String dirname) {
        final File f = new File(dirname);
        if (!f.exists()) {
            return false;
        }
        if (f.isFile()) {
            return false;
        }
        return true;
    }
}

Related

  1. isLegalFile(String filePath)
  2. isLegalFilePath(File inBasePath, File inResourcePath)