Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Delete file

 
Adam Teg
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my program, I open a file and after processing try to delete it. It will not delete. When I try to delete it mannually, it tells me it is being used by my program. I close the file readers in my program, what else can I do?

Thanks
 
Ravi Kotha
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a similar problem. Then I put the statement after closing all streams to read/write. It got deleted successfully. In your case you are saying you have closed streams. Can you give a rough picture of your code?
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Steblay:
In my program, I open a file and after processing try to delete it. It will not delete. When I try to delete it mannually, it tells me it is being used by my program. I close the file readers in my program, what else can I do?

Thanks


do what the other guy said...

or maybe try to null the object when you are done with it and create a new one witht the absolute path name, then .delete();
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic