renameTo - must be attribues problem

as i mentioned before, the renameTo won't move files.

I tried to do it manually with a command like this:

System.out.println(new File("c:\\test\\high.mp3").renameTo(new File("c:\\test\\high1.mp3")));

and sometimes it works, and sometimes after it moves or manually renamed by me, it wont renameTo it!!!!! it drives me crazy! must be something with attributes or something!

you must help me how to fix this

[553 byte] By [renameToa] at [2007-11-26 18:39:38]
# 1

Did you read the API docs?

Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and 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.

Or maybe someone's still got a hold on that file.

CeciNEstPasUnProgrammeura at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 2
you must be right! couse if i write this only command in another class. it works fluently... so i must have locked this file in previous commands.how can I release the lock on a file?thanks
renameToa at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 3
> you must be right! couse if i write this only command> in another class. it works fluently... so i must have> locked this file in previous commands.> how can I release the lock on a file?Close all the streams...
CeciNEstPasUnProgrammeura at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 4
Im a little newbie... can you tell me how?isnt enough to do file1 = null;?thanks
renameToa at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 5
> Im a little newbie... can you tell me how?> > isnt enough to do file1 = null;?> > thanksThat isn't a stream. You should call close on all readers, writers, inputstreams and outputstreamsKaj
kajbja at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 6
i dont use streamers... only File objects....
renameToa at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 7
> isnt enough to do file1 = null;?This does nothing. If you don't open streams, you can't close them...
CeciNEstPasUnProgrammeura at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 8
so what can i do?the only thing that can lock me is another File object that refers to a upper directory from the file i am trying to move! if I change them it works... I just now saw that... how can I release or throw them away? from the memory
renameToa at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 9
A File object does not lock resources. Something else in the os might have locked the file (e.g. an mp3 player)Kaj
kajbja at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...
# 10
ok. i found the problemyou are absulotly right...what locks my file is another object that hold a reference to the File object.I would like to create a method in this class that destroys the object after use... is there any possibility to do so?thanks
renameToa at 2007-7-9 6:13:41 > top of Java-index,Java Essentials,Java Programming...