A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Java SE 8 for the Really Impatient
this week in the
I/O and Streams
Move File from one directory to another
Ravi Kiran Va
Joined: Apr 18, 2009
Aug 06, 2010 11:41:06
I am trying to move File from one directory to another directory using renameTo Option , but i am always getting false as the return type , with no Exception .
File oldFile = new File("C:/One/sai.txt"); File newFile = new File("C:/Two"); boolean result = oldFile.renameTo(newFile); System.out.println("The result is " + result);
Save India From Corruption - Anna Hazare.
Joined: Oct 14, 2005
Aug 06, 2010 11:57:05
Presumably C:\Two already exists (perhaps it's actually the directory you wanted to move the file to), so you can't rename C:\One\sai.txt to that. Did you actually want to rename it to C:\Two\sai.txt? If so then do that.
I agree. Here's the link:
subject: Move File from one directory to another
problem opening a new word file
renaming an uploaded file
Opening CSV file in ReadOnly while writing data to it
Usage of list() with File to search files and directories
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014