How to find out why renameTo() failed?
问题 I am using WinXP. I use java to generate a list of files. The file will be created as abc.txt.temp at first, and after completing the generation, it will be renamed to abc.txt. However, when i generating the files, some of the files failed to be renamed. It happen randomly. Is there anyway to find out the reason why it failed? int maxRetries = 60; logger.debug("retry"); while (maxRetries-- > 0) { if (isSuccess = file.renameTo(file2)) { break; } try { logger.debug("retry " + maxRetries);