This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Java in General and the fly likes Rename a directory in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Rename a directory in Java" Watch "Rename a directory in Java" New topic

Rename a directory in Java

Rob Bass
Ranch Hand

Joined: Aug 28, 2001
Posts: 67
Hello all,
I tried renaming a single directory using renameTo and that worked, but when I added subdirectories it no longer worked?? Anyone know an easy way to do the above?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Which part no longer worked? Can you show us the code that you used?

"JavaRanch, where the deer and the Certified play" - David O'Meara
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
hi Rob,
replying to ur post after long...
well, i created dir hierarchy as,
i used following code and it worked for me,

hope it works for u as well. make sure u dont have a file with the same dir name in any case.
I agree. Here's the link:
subject: Rename a directory in Java
jQuery in Action, 3rd edition