renameTo() is failing to move a file to another directory in Windows 2000 ?

Hi All,

I am trying to move a file from one directory to another. i don't have any files in the directory where i am moving. so there is no possibility of same file exist.

i also unable to find the reasons why it is not moving...

Can anybody help me on this? How to debug such problems? I think this is a flaw in the java since we could not able to trace the errors of these kinds of problems......

Why java doesn't handle such important scenerios?

Please help me...Its very urgent..

Thanks,

J.Kathir

[551 byte] By [jkathira] at [2007-10-2 20:58:50]
# 1

Check the docs:

[url=http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#renameTo(java.io.File)]http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#renameTo(java.io.File)[/url]

Renames the file denoted by this abstract pathname.

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.

prometheuzza at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 2
Is not java expert is here to answer this question ?
jkathira at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 3
How to find the reasons if it is not successful.
jkathira at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 4
any other way to achieve renameTo()it is not working most of the times..how to find the reasons?is there is any other API which does this better
jkathira at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 5
Are you sure the file is not in use? Like held open by a reader or a writer? WIndows won't let you move or delete a file in use; Unices usually will.
BIJ001a at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 6
yes i am sure the file is not in use by any process.
jkathira at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 7
Not even by the very JVM?
BIJ001a at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 8
> yes i am sure the file is not in use by any process.Can you delete the file with the File.delete() method?
prometheuzza at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 9
not deleting
jkathira at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 10
If by "not deleting()" mean you are can't even delete it, then some process probably has a lock on it. Find out why, then should be able to move it. This is probably an operating system issue rather than a coding problem.
Dick_Adamsa at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 11
> not deletingThen I'm pretty sure the file is in use.
prometheuzza at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 12
http://www.sysinternals.com/Utilities/Filemon.html
BIJ001a at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...
# 13
Hi close all the streams pointing to the file.it will help
alwinjosha at 2007-7-13 23:43:34 > top of Java-index,Java Essentials,Java Programming...