GeeCON Prague 2014*
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


JavaRanch » Java Forums » Java » Java in General
Bookmark "Rename a directory in Java" Watch "Rename a directory in Java" New topic
Author

Rename a directory in Java

Rob Bass
Ranch Hand

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

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: 1871
hi Rob,
replying to ur post after long...
well, i created dir hierarchy as,
testDir
-file1
-subdir1
-subdir2
-file2
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.
regards
maulin.
 
GeeCON Prague 2014
 
subject: Rename a directory in Java