Two Laptop Bag*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
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.
 
jQuery in Action, 2nd edition
 
subject: Rename a directory in Java
 
Similar Threads
Basic Servlet Problem
Core JSF by Geary & Horstmann. Chapter 1: login example
I feel kinda dumb but...
Cannot Find Symbol, Interfaces
Cant compile my java files on DOS