File.renameTo()
hi,
I have an application that reads a file "Flat.txt" for a sorce directory and loads the Database and moves the file "Flat.txt" to destination directory. This application runs once in ten days and the name of the file remains the same "Flat.txt".
I am using File.renameTo() and it works fine for the first time. But if the application runs second time it loads the new data to Database but the File.renameTo() function returns false i.e if the file already exists in the directory it returns false instead of overwriting.
Any help is greatly appreciated.
Thanks
Viji
[605 byte] By [
vijia] at [2007-10-2 6:24:47]

Why don't you check to see if the destination file already exists, and delete it if it does, before calling renameTo?
[quote]
public boolean renameTo([url http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html]File[/url] dest)
Renames the file denoted by this abstract pathname.
Many aspects of the behavior of this method are inherently platform-dependent: ... it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful.
[/quote]