Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Delete Directory

 
bob morkos
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you write a java application that deletes a directory. An example would help a lot. And is it posible to read the size of a file in a java program. Thanks.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The File class has methods delete() and length() which accomplish what you need.
 
Spencer J Lee
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I noticed that the delete method of the File class can only delete a directory if its empty. Is there an existing way or method to recursively delete a directory, its subdirectories, and files (i.e. rm -rf)? Or is this something I'll need to put together myself.
Thanks ahead of time.
Spencer
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Spencer Lee:
Hello,
...Or is this something I'll need to put together myself.

Yup
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!