File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Delete Directory

 
bob morkos
Ranch Hand
Posts: 104
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic