This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes How rename a Directory ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How rename a Directory ?" Watch "How rename a Directory ?" New topic

How rename a Directory ?

Srinivasa Vallabha

Joined: Mar 08, 2001
Posts: 15
Hi all,
I want to rename a directory, i know using renameTo() method we have to create file objects all the files which are there in a directory to its destination and then we need to delete the old one. But my question is, there is any other way to do this ?
Please help me....
Srinivasa Vallabha
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Srinivasa,
A File object can point to a file or a directory. All methods will work regardless of which is used. Therefore, you can easily do the following:

and it will work!
Consider Paul's rocket mass heater.
subject: How rename a Directory ?
Similar Threads
renaming all files in one dir
Error in Servlet compilation
Renaming a file -- what's wrong with this code ?
Without ROOT directory
JDBC Driver in Tomcat 4.0