Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2004

Tip: Looking for answers? Try searching our database.

File.renameTo

Thread view: 
Peter Kirk - 19 May 2004 16:24 GMT
Hi there

if File.renameTo method returns true does that mean that the file is
definitely moved? Sometimes I see this method returning true, and yet the
file is not moved at all - any general ideas about where a problem could be?

Peter
Chris Smith - 19 May 2004 16:44 GMT
> if File.renameTo method returns true does that mean that the file is
> definitely moved? Sometimes I see this method returning true, and yet the
> file is not moved at all - any general ideas about where a problem could be?

Yes, the file is definitely moved if that method returns true.  Can you
post a self-contained example of code that fails?

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Peter Kirk - 19 May 2004 16:47 GMT
> > if File.renameTo method returns true does that mean that the file is
> > definitely moved? Sometimes I see this method returning true, and yet the
> > file is not moved at all - any general ideas about where a problem could be?
>
> Yes, the file is definitely moved if that method returns true.  Can you
> post a self-contained example of code that fails?

Hi, thanks heaps for the reply - I have found my problem. It was because I
was using the wrong path to write to, and ended up "moving" the file to
itself.

(It was via a complicated chain of events, of which the root cause was
probably that the "constant" String representing the destination directory
was not declared final meaning that another programmer unwittingly changed
its value).

Peter
Roedy Green - 19 May 2004 18:56 GMT
>if File.renameTo method returns true does that mean that the file is
>definitely moved? Sometimes I see this method returning true, and yet the
>file is not moved at all - any general ideas about where a problem could be?

The safest and fastest sort of rename is when the new name is in the
same directory.

If it is on a different drive, it definitely won't work.

See http://mindprod.com/jgloss/temporaryfiles.html for how to create
temps that are in the right place for renaming.

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.