dcsimg
File.renameTo() fails
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Hitoshi_Gosen
Posted On:   Wednesday, May 12, 2004 01:27 AM

Hey All,

I have a program that moves a file to an another directory with File.renameTo() method.

The problem is that it works sometimes and it doesn't some other times.

Any ideas on what's going on and what to do about it?



thanks in advance,

Toshi

Re: File.renameTo() fails

Posted By:   Sean_Owen  
Posted On:   Wednesday, May 12, 2004 08:10 AM

From the File.renameTo() javadocs: "Whether or not this method can move a file from one filesystem to another is platform-dependent. The return value should always be checked to make sure that the rename operation was successful."

Re: File.renameTo() fails

Posted By:   Jani_Kaarela  
Posted On:   Wednesday, May 12, 2004 03:19 AM

How exactly does it fail? If it doesn't throw an exception (NullPointerException or SecurityException, see the JavaDoc of java.io.File), but simply returns false, the failure is probably caused by the underlying OS/filesystem. You can try to debug by calling canWrite() etc. on the renameTo() destination File.
About | Sitemap | Contact