Filename rename problem

Hi all,

My problem is sometime i cant rename the filename with my program. For examp

le, before i edit the content of particular file, the filename is file_01.xm

l, then after i edit it and click the save button, i want to rename the file

name to file_01_edited.xml. So, sometime it work but sometime not.

Below is my some coding. Anybody can help me? !0s first.....

String nfilename = tokenString[0] +"_edited";

File original =new File(directoryname +"\\" + "original" + "\\" + tokenStr

ing[0] +".txt");

File noriginal =new File (directoryname +"\\" + "original" + "\\" + nfilen

ame +".txt");

boolean success1 = original.renameTo(noriginal);

File process =new File(directoryname +"\\" + "process" + "\\" + tokenStrin

g[0] +".xml");

File nprocess =new File (directoryname +"\\" + "process" + "\\" + nfilenam

e +".xml");

boolean success2 = process.renameTo(nprocess);

File edit =new File(directoryname +"\\" + "edit" + "\\" + tokenString[0] +

".xml");

File nedit =new File(directoryname +"\\" + "edit" + "\\" + nfilename + ".x

ml");

boolean success3 = edit.renameTo(nedit);

[2164 byte] By [WanHunga] at [2007-10-3 3:39:37]
# 1
You mean apart from the usual reasons such as file not closed, or target already exists?
ejpa at 2007-7-14 21:35:07 > top of Java-index,Core,Core APIs...
# 2
a..........izzit possible when i open a file.....then rewrite it.....and no close....so make me cant rename...izzit?
WanHunga at 2007-7-14 21:35:07 > top of Java-index,Core,Core APIs...
# 3
itizzzzzz
ejpa at 2007-7-14 21:35:07 > top of Java-index,Core,Core APIs...
# 4
Some platforms/file systems (e.g. Unices) will by default (.i.e. without extra locking) allow to rename or remove an open file, some (e.g. Windows) won't.
BIJ001a at 2007-7-14 21:35:07 > top of Java-index,Core,Core APIs...
# 5
Mulitpost: http://forum.java.sun.com/thread.jspa?threadID=761800&messageID=4348003#4348003
BIJ001a at 2007-7-14 21:35:07 > top of Java-index,Core,Core APIs...