Can you edit your post (click on the paper and pencil icon) and put your code into code tags. This will make it much easier to read. It's difficult to read your code but the only code i could see that you might be using to delete a file is a call to deleteOnExit. This will not delete the file until you exit the JVM (i.e. your program finishes). Try using the delete method instead and see if that fixes your problem.
Apparently, this is continued from here. Damodar, in general it's better to continue a topic in the same thread you started in, if you're really just continuing the exact same discussion. That way people have access to all the earlier info and don't waste time saying things that have already been said before. Thanks.
may be this come under same thread, but i got some different answer, which i not got with previous thread. there was no time wasting as i not mentioned, that please refer previous thread for more information , i mentined every thing clearly in the present thread.Also the code what i metioned before is different with the previous thread.
1. Is this a standalone program? If yes then deleteOnExit should work since your jvm will exit once you are done with your program. 2. If you intend to only renmae the file then why you are not using only renameTo method in File Class. 3. I think variable newname should be reset in each iteration 4. Also its not clear what is to be done in case directory have all files already renamed.
I have modified your code below with assumption that if both old and new file you wanted to create already exists then new file will be over-written.