import java.io.*;
class DeleteFile
{
public static void main(String[] args)
{
try
{
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("file.txt"));
bufferedWriter.write("Welcome");
bufferedWriter.close();
boolean status = (new File("file.txt")).delete();
if (status)
{
System.out.println("File deleted successfully");
}
BufferedReader bufferedReader = new BufferedReader(new FileReader("file.txt"));
String str;
while ((str = bufferedReader.readLine()) != null)
{
System.out.println(str);
}
bufferedReader.close();
}
catch (IOException ioe)
{
System.out.println("File not found");
ioe.printStackTrace();
}
}
}