aspose file tools*
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
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: 36
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: 19692
    
  20

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to rename file