Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to delete a specific file after searching in all the directory?  RSS feed

 
sanidhya kumar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i am trying. what changes shall i make here to search and delete a specific file ?

 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already print the file name using the getName() method in the java.io.File API. So to delete a specific file just compare it with the file name you need to delete.

To delete, you can use the delete() method in the same File class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!