Java mkdir makeDirForPath(String path)

Here you can find the source of makeDirForPath(String path)

Description

make Dir For Path

License

Open Source License

Declaration

public static void makeDirForPath(String path) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    public static String fileseperator = System.getProperty("file.separator");

    public static void makeDirForPath(String path) {
        File file = new File(path);
        File dir = new File(file.getParent());
        makeDir(dir.getPath());//from  ww w . j  av  a2  s. c  o  m
    }

    /**
     * @param path
     */
    public static synchronized void makeDir(String path) {
        File dir = new File(path);
        if (!dir.exists()) {
            dir.mkdirs();
        }
    }

    /**
     * create directory method
     *
     * @param parent directory
     * @param child  directory
     */
    public static synchronized void makeDir(String parent, String child) {
        StringBuffer mkdir = new StringBuffer(parent);
        mkdir.append(fileseperator);
        mkdir.append(child);
        makeDir(mkdir.toString());
    }
}

Related

  1. makeDirectory(String outputDirectory, String directoryName)
  2. makeDirectory(String path)
  3. makeDirectory(String path, String directoryName)
  4. makeDirectory(String sDir)
  5. makeDirectoryWorldAccessible(File directory)
  6. makeDirIfNotExists(File... paths)
  7. makeDirRecursive(File f)
  8. makeDirs(@Nullable File dir)
  9. makeDirs(File dir, int numTries)