Well Ganesh you are getting ubnormal behaviour because you are using multiple File objects to represent files inside directories that. Look at this example

If you run this program, it will create a directory named dir1, then rename it to dir2. Neither will it create a new file, nor will it throw any FileNotFoundException. Same is the case with files

Again file1.txt will be created and will be renamed. It will not be copied.

I don't know the exact reason why your program is behaving that way, but it is surely because you are using too many things in it. The most suspicious one I think is using a PrintWriter to write to a File that you have renamed. File objects represent file paths. So the file object after renaming will point to the old path.

This is not complete explanation so let's see what others have to say...