
how to delete file after creating file

import java.io.*;
class CreateAndDeleteFile
{
public static void main(String[] args)
{
try{
File f=new File("C:/file.txt");
f.createNewFile();
System.out.println("File is created!");
f.delete();
System.out.println("File is deleted!");
}
catch(Exception e){
System.out.println(e);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.