Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Move file from one folder to another  RSS feed

 
Shyju Lakshman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

What is the best way to move a file from one folder to another.
I have been using the renameTo() method, but it doesn't seem to work always.

And also, I need to move the file from a windows folder to a linux machine.

Thanks in advance.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

renameTo() will generally work within one filesystem (one disk), but it won't move a file from one place to another. To do that, you have to open the file, copy the data to the new location, and delete the old file.
 
Shyju Lakshman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ernest,

Many thanks for the welcome and the reply.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!