Home Tutorial Java Core Files Java file delete

 
 

Java file delete
Posted on: August 3, 2006 at 12:00 AM
Advertisement
In this section, you will learn how to delete a file.

Java file delete

In this section, you will learn how to delete a file.

Description of code

Java makes file manipulation easier by providing many useful tools. Through the use of these tools, you can easily perform file operations. Here we are going to delete a file. For this, we have created an object of File and call the method delete() through the object. This method delete the file from the given path name.

Here is the code:

import java.io.*;

public class FileDelete {
	public static void main(String[] args) {
		File f = new File("C:/newfile.txt");
		f.delete();
	}
}

Through the method delete(), you can delete the file from the given path name.

Advertisement

Related Tags for Java file delete:


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: August 3, 2006

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com