File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Delete Directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Delete Directory" Watch "Delete Directory" New topic
Author

Delete Directory

bob morkos
Ranch Hand

Joined: Sep 06, 2001
Posts: 104
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

Joined: Jan 30, 2000
Posts: 18671
The File class has methods delete() and length() which accomplish what you need.


"I'm not back." - Bill Harding, Twister
Spencer J Lee
Ranch Hand

Joined: Mar 19, 2003
Posts: 30
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

Joined: Jan 27, 2004
Posts: 202
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
 
subject: Delete Directory
 
Similar Threads
cannot import package
creation of new directory inside an exisiting directory
Where in Javawebserver2.0 should I place my Html , Jsp and Java programs
db2jcc.jar
Creating Directories using Servlet