Home Tutorial Java Core Files Java file new directory

 
 

Share on Google+Share on Google+
Java file new directory
Posted on: May 22, 2006 at 12:00 AM
Advertisement
In this section, you will learn how to create a new directory.

Java file new directory

In this section, you will learn how to create a new directory.

Description of code:

This is a common task. The java.io.package provides various useful tools that has made the file handling easier. Programming has now became much easier.

You can see in the given example, we have created an object of File class and specify a directory which you want to create. 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 FileNewDirectory {
	public static void main(String args[]) {
		File file = new File("Hello");
		file.mkdir();
	}
}

By using the method mkdir(), you can create a directory in the given path.

Advertisement

Related Tags for Java file new directory :


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: May 22, 2006

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com