In the program u have not mentioned any delete() function so how can it be able to delete the file....please update the code
import java.io.File; import java.io.*;
public class DeletingFile { public static void main(String args[])throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the file name to delete:"); String file_name = in.readLine(); File file = new File("file_name"); boolean exist = file.exists(); if (!exist){ System.out.println("File was not exist....\n"); } else { if(file.delete()) { System.out.println("File successfully deleted....\n");
} else System.out.println("File was not successfully deleted.\n"); } } }