How to create directories recursively in java?

DeeKay March 8, 2012 at 1:12 am · java.io

Below java code shows how to create directories recursively –

/****************************************************************************************
 * Created on 03-2012 Copyright(c) http://kodehelp.com All Rights Reserved.
 ****************************************************************************************/
package com.kodehelp.javaio;

import java.io.File;

/**
 * Created by http://kodehelp.com
 * Date: 03/05/2012
 */
public class RecursiveDirectoryCreation {

	public static void main(String[] args) {
		String directories = "C:\\001\\002\\003\\004\\005\\006\\007\\008\\009";
        File file = new File(directories);

        boolean passFail = file.mkdirs();
        System.out.println("Directory Creation Status = " + passFail);

	}

}