Home Tutorial Java Core Files Java file mkdirs

 
 

Share on Google+Share on Google+
Java file mkdirs
Posted on: April 14, 2006 at 12:00 AM
Advertisement
This section demonstrates you the use of method mkdirs().

Java file mkdirs

This section demonstrates you the use of method mkdirs().

Explanation:

The File class in java.io package works with both files and directories. This class provides many useful functions for operating the files and directories. Here we will discuss the function mkdirs().

The method mkdirs() actually creates directory structures. It creates the directory named by the abstract pathname, including any necessary but nonexistent parent directories. In the given code, we have specified C:/Hello/Java/File, so it will first create the non existent parent directories "C:/Hello", then "C:/Hello/Java", and then finally create our directory "C:/Hello/Java/File".

Here is the code:

import java.io.*;

public class FileMkdirs {
	public static void main(String[] args) {
		File f = new File("C:/Hello/Java/File");
		f.mkdirs();
	}
}
Advertisement

Related Tags for Java file mkdirs:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 14, 2006

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com