Java file mkdir()


 

Java file mkdir()

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

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

Java file mkdir()

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

Description of code:

Now the manipulation of files is become an easy task. Java has provide various useful classes and their methods to handle the file operations. This makes the programming much easier. If you want to create a file, delete a file, create a directory then by just using the built in methods provides by the java.io.* package, you will get the required result.

You can see in the given example, we have created an object of File class and parse a string representing the directory name along with the path. Then we have called the method mkdir() through the object of file class. On executing the given code, you will get the newly generated directory in the given path.

Here is the code:

import java.io.*;

public class Filemkdir {
	public static void main(String[] args) {
		File f = new File("C:/hello");
		f.mkdir();
	}
}

Through the use of method mkdir(), you can create a directory of your choice.

Ads