Java Create Directory mkdirs(String destination)

Here you can find the source of mkdirs(String destination)

Description

Creates directory specified by destination, and all its parents if they don't exist.

License

Open Source License

Parameter

Parameter Description
destination the directory to create.

Declaration

public static void mkdirs(String destination) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008-2009 SWTBot Committers and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * //  w ww .j  av  a  2  s.  c  o  m
 * Contributors:
 *     Ketan Padegaonkar - initial API and implementation
 *******************************************************************************/

import java.io.*;

public class Main {
    /**
     * Creates directory specified by destination, and all its parents if they don't exist.
     * 
     * @param destination the directory to create.
     */
    public static void mkdirs(String destination) {
        mkdirs(new File(destination));
    }

    /**
     * Creates directory specified by destination, and all its parents if they don't exist.
     * 
     * @param destination the directory to create.
     */
    public static void mkdirs(File destination) {
        if (destination.exists()) {
            return;
        }
        if (!destination.mkdirs()) {
            throw new RuntimeException("Unable to create directory [" + destination + "].");
        }
    }
}

Related

  1. mkdirs(final File file)
  2. mkdirs(final File outdir, final String path)
  3. mkdirs(final String path)
  4. mkdirs(final String path)
  5. mkdirs(String destDir)
  6. mkdirs(String dirName)
  7. mkdirs(String fileName, String baseName)
  8. mkdirs(String filePath)
  9. mkdirs(String filePath)