| Author |
Forced Directory Deletion
|
Tom Johnson
Ranch Hand
Joined: May 11, 2005
Posts: 142
|
|
Hi, Is there any way to force java to delete a directory, even if its not empty - similar to rm -f <dir_name> in unix? Would it be just as handy to create a script with rm -f <dir_name> and call that from the java program? Thanks /Tom
|
<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16815
|
|
Originally posted by Tom Johnson: Hi, Is there any way to force java to delete a directory, even if its not empty - similar to rm -f <dir_name> in unix? Would it be just as handy to create a script with rm -f <dir_name> and call that from the java program? Thanks /Tom
The closest equivalent to "rm -f <dir_name>" in Windows is probably "rmdir /s/q <dir_name>". Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Tom Johnson
Ranch Hand
Joined: May 11, 2005
Posts: 142
|
|
Hi, Is that not just a DOS command? - I meant a piece of java code or API to allow me to to it /tom
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
|
I think you would have to recursively delete the contents of the directory, before deleting the directory itself.
|
Joanne
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16815
|
|
Originally posted by Tom Johnson: Hi, Is that not just a DOS command? - I meant a piece of java code or API to allow me to to it /tom
Sorry... I was under the impression that you were calling Runtime.exec() under unix, and needed the equivalent for DOS. Henry
|
 |
 |
|
|
subject: Forced Directory Deletion
|
|
|