Java Path Create makePath(String basePath)

Here you can find the source of makePath(String basePath)

Description

Makes folders along the specified path

License

Open Source License

Declaration

static public void makePath(String basePath) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**//from w w  w  .  j a  v a  2  s  . c  o m
     * Makes folders along the specified path
     */
    static public void makePath(String basePath) {
        File path = new File(basePath);
        try {
            if (!path.exists()) {
                if (!path.mkdirs())
                    //Did someone sneaky make it?
                    if (!path.exists())
                        throw new RuntimeException("Failed to create directory:" + basePath);
            } else if (!path.isDirectory()) {
                throw new RuntimeException("Something is already has this name, and it's not a dir: " + basePath);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("Failed to create directory:" + basePath);
        }
    }
}

Related

  1. makePath(Collection files)
  2. makePath(File copyTo)
  3. makePath(File cwd, String path)
  4. makePath(final String dir, final String... jars)
  5. makePath(String filename, String savePath)
  6. makePath(String path1, String path2)
  7. makePath(String... elements)
  8. makePath(String... elements)