Share on Google+Share on Google+

Java file mkdirs

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

Java file mkdirs

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


The File class in 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:


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


Posted on: April 14, 2006 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.