Java Directory Create nio mkdirs(Path path)

Here you can find the source of mkdirs(Path path)

Description

Creates a directory by creating all nonexistent parent directories first.

License

Open Source License

Parameter

Parameter Description
path the directory to create

Declaration

public static void mkdirs(Path path) 

Method Source Code

//package com.java2s;
/*/*from  w  w w  .  j a v  a2  s .  com*/
 * SonarLint Core - Client API
 * Copyright (C) 2009-2017 SonarSource SA
 * mailto:info AT sonarsource DOT com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.io.IOException;

import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    /**
     * Creates a directory by creating all nonexistent parent directories first.
     *
     * @param path the directory to create
     */
    public static void mkdirs(Path path) {
        try {
            Files.createDirectories(path);
        } catch (IOException e) {
            throw new IllegalStateException("Unable to create directory: " + path, e);
        }
    }
}

Related

  1. mkdir(final File dir)
  2. mkdir(final File dir)
  3. mkdirs(Path dir, FileAttribute... attrs)
  4. mkdirs(Path path)
  5. mkPath(Path nf)