This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Java in General and the fly likes Unable to rename file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Unable to rename file" Watch "Unable to rename file" New topic
Author

Unable to rename file

Siddhesh Khedekar
Ranch Hand

Joined: Nov 09, 2009
Posts: 42
Hi Experts,

I am tryin following code -


The folder D:\test already exists.
but not able to rename the file and getting output

Results.dat
Results.dat
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19908
    
  23

File.renameTo does not change the File object. If it returns true it renames the file, yes, but the File object is immutable and stays exactly the same. Instead of using the old value of f you should reassign it:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
rocket mass heater kickstarter
 
subject: Unable to rename file