• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to rename file

 
Siddhesh Khedekar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic