Delete file or directory in Java
Description
The following code shows how to delete file or directory.
Example
/*ww w.j ava 2 s. c o m*/
import java.io.File;
public class Main {
public static void main(String[] args) throws Exception {
File file = new File("C:/Demo.txt");
System.out.println(file.delete());
}
}
The code above generates the following result.