In this tutorial, I am writing simple program about How to create directory in Java.

The new directory can be created using Java with help of mkdir() method. Which is part of class. If the directory is created successfully it will return true. It will return false if the directory is already available. The example program were attached in the post.

package com.dineshkrish.files;
* @author Dinesh Krishnan
public class CreatingDirectoryExample {
public static void main(String[] args) {
// Parent Path
String path = "C:\\Users\\dineshkrishnan\\";
// Directory Name
String directoryName = "myImage";
File file = new File(path + directoryName);
// Creating the directory in specified parent path
boolean creationStatus = file.mkdir();
if(creationStatus) {
System.out.println("Directory is Created");
} else {
System.out.println("Directory is Not Created");


1. Java API Documentation


No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *