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
Output :
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
0 comments:
Post a Comment