Java Directory Check checkDirs(String dirName)

Here you can find the source of checkDirs(String dirName)

Description

Check if dir exists.

License

Open Source License

Parameter

Parameter Description
dirName a parameter

Declaration

public static File checkDirs(String dirName) 

Method Source Code


//package com.java2s;
/*//from  w  w w .ja  va  2 s .c  om
Copyright (c) 2009 Mindaugas Greibus (spantus@gmail.com)
Part of program for analyze speech signal 
http://spantus.sourceforge.net
    
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

import java.io.File;

public class Main {
    /**
     * Check if dir exists. if not create all of them
     * 
     * @param dirName
     * @return
     */
    public static File checkDirs(String dirName) {
        File dir = new File(dirName);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        return dir;
    }
}

Related

  1. checkDirectoryArray(String[] names)
  2. checkDirectoryInWorkspace(String directoryName)
  3. checkDirPath(final String path)
  4. checkDirs(File f)
  5. checkDirs(String dir)