This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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

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!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: How rename a Directory ?