Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!