Create directory with parent directories with java



User Rating:  / 2
PoorBest 
Details
Category: Java
Created on Friday, 16 November 2012 10:16
Last Updated on Friday, 16 November 2012 10:16
Published on Friday, 16 November 2012 10:16
Written by Administrator
Hits: 5732

Simple code for create directory with parrents direcory.

e.g. :  c:\dir1\dir2\dir3\direcory

View source
package com.developerpages.snippets.core;
 
import java.io.File;
 
public class CreateDirectoryWithParentDirectories {
 
    public static void main(String[] args) {
        File dir = new File("c://dir1/dir2/dir3/directory");
        boolean directoriesCreated = dir.mkdirs();
        if (directoriesCreated) {
            System.out.println("Directories created");
        } else {
            System.out.println("Directories not created");
        }
 
    }
}