Create directory with parent directories with java
Details
- 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: 8509
Simple code for create directory with parrents direcory.
e.g. : c:\dir1\dir2\dir3\direcory
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");
}
}
}