We are moved to new domain
Click -> www.ehowtonow.com
Sunday, 21 May 2017

How to Create Directory using Java File.mkdirs

boolean java.io.File.mkdirs()

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

Returns:
true if and only if the directory was created, along with all necessary parent directories; false otherwise

Throws:
SecurityException - If a security manager exists and its java.lang.SecurityManager.checkRead(java.lang.String) method does not permit verification of the existence of the named directory and all necessary parent directories; or if the java.lang.SecurityManager.checkWrite(java.lang.String) method does not permit the named directory and all necessary parent directories to be created

CreateDirectories.java
package com.javatutorialcorner.regex;

import java.io.File;

public class CreateDirectories {

 public static void createDirectory(){
   String directories = "C:\\JTC\\Java\\Examples\\Directory\\File";
      File file = new File(directories);
      boolean status = file.mkdirs();
      System.out.println("Directory Created : " + status);
 }
 
 public static void main(String args[]){
  createDirectory();
 }
}


Output :
Directory Created : true

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: How to Create Directory using Java File.mkdirs Rating: 5 Reviewed By: eHowToNow