• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rename a directory in Java

 
Rob Bass
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which part no longer worked? Can you show us the code that you used?
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic