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

Deleting and Renaming files from the system

 
Javed Akhtar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody,
I'm making new files in my system through my java application
but I'm not able to delete or rename those files from my application
Thanking you,
Javed
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Send us a sample of your code. Make sure it contains the section with the file I/O.
 
Grant Crofton
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably need to use java.io.File, which has methods for deleting and renaming files.
File holds a file name/path, or a directory. Although it does not actually hold the contents of a file, you can use it to do stuff with the file it points to, like set it's last modified attribute etc.

(you often have to check for exceptions, normally SecurityExceptions, when working with File)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!