File Deletion
public class FileDelete {
public static void main(String[] args) {
File f = new File("D://file3.txt");
if (f.exists()) {
System.out.println("File exists..!!");
f.delete();
System.out.println("File deleted successfully..!!");
} else {
System.out.println("No such file exists");
}
}
}
Output:
File exists..!!
File deleted successfully..!!