Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forced Directory Deletion

 
Tom Johnson
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Henry Wong
author
Marshal
Pie
Posts: 21212
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tom Johnson
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you would have to recursively delete the contents of the directory, before deleting the directory itself.
 
Henry Wong
author
Marshal
Pie
Posts: 21212
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic