Java Create Directory mkdirs(final File dirs)

Here you can find the source of mkdirs(final File dirs)

Description

Creates all folders at once.

License

Open Source License

Declaration

public static void mkdirs(final File dirs) throws IOException 

Method Source Code


//package com.java2s;
import java.io.File;

import java.io.IOException;

public class Main {
    private static final String MSG_NOT_A_DIRECTORY = "Not a directory: ";
    private static final String MSG_CANT_CREATE = "Can't create: ";

    public static void mkdirs(String dirs) throws IOException {
        mkdirs(new File(dirs));
    }/* www. j  a  v a 2s .  c  o m*/

    /**
     * Creates all folders at once.
     */
    public static void mkdirs(final File dirs) throws IOException {
        if (dirs.exists()) {
            if (!dirs.isDirectory()) {
                throw new IOException(MSG_NOT_A_DIRECTORY + dirs);
            }
            return;
        }
        if (!dirs.mkdirs()) {
            throw new IOException(MSG_CANT_CREATE + dirs);
        }
    }
}

Related

  1. mkDirs(File path)
  2. mkdirs(File path)
  3. mkdirs(File path)
  4. mkdirs(File path)
  5. mkdirs(final File aDirectory)
  6. mkdirs(final File f)
  7. mkdirs(final File file)
  8. mkdirs(final File outdir, final String path)
  9. mkdirs(final String path)