In this section, you will learn how a specified file or directory is deleted. For deleting a file from a directory you need to give the file name to be deleted.
Description of program:
The following code of program deletes a file from a directory. In this program the compiler will ask to enter the name of the file to be deleted. For this we have used "BufferedReader(new InputStreamReader(System.in));" method as you very well know about it. If the file exists in the directory then it will be deleted otherwise we will get a message that "file was not successfully deleted".
Output of the program:
Enter the file name to delete:wonderful.txt
File was successfully deleted.
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: February 27, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles