In my app I\'m writing a file to store some execution info and once the execution is done I want to delete the temp file. The issue is even after file close or flush by streams
That seems to indicate that you did not call close().
close()
Reason: in the begin time of java, the Object.finalize() method was used to clean up on garbage collection, and for I/O it did a close().
Object.finalize()
Until the file is in use (not closed), the file cannot be deleted on Windows.