Home Tutorial Java Core Files Java file mkdirs

 
 

Java file mkdirs
Posted on: April 14, 2006 at 12:00 AM
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();
	}
}

Related Tags for Java file mkdirs:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.