I have a simple program for which will create one folder, copy some file from another folder to the newly created folder, compress the newly created folder and delete the newly created folder which had been compressed.
My program is creating new folder compressing it, but not able to delete it.
and if i hard code the path like bellow and put it on the top of the main method it deletes the folder. fine.
same line if i move to the end of the method it does not delete folder.
What could be the possible reason for it. i m not able to understand it.
You don't ever actually close the files you're reading from. You set "in" to null, but you don't ever call in.close(). On Windows, an open file cannot be deleted. I also don't see your deleteDir() routine, but hopefully it deletes all the files in a folder before deleting the folder, as Windows, again, won't delete a folder with files in it.