title: How to find out why renameTo() failed?
body: <p>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.</p>
  
  <p>However, when i generating the files, some of the files failed to be renamed. It happen randomly.</p>
  
  <p>Is there anyway to find out the reason why it failed?</p>
  
  <pre class="lang-java prettyprint-override"><code>int maxRetries = 60;
  logger.debug("retry");
  while (maxRetries-- &gt; 0)
  {
      if (isSuccess = file.renameTo(file2))
      {
          break;
      }
      try
      {
          logger.debug("retry " + maxRetries);
          Thread.sleep(1000);
      }
      catch (InterruptedException e)
      {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }   
  }
  
  //file.renameTo(file2);
  Thread.currentThread().getThreadGroup().getParent().list();
  </code></pre>
  
  <p>And the result:</p>
  
  <pre class="lang-none prettyprint-override"><code>[DEBUG][2009-08-25 08:57:52,386] - retry 1
  [DEBUG][2009-08-25 08:57:53,386] - retry 0
  java.lang.ThreadGroup[name=system,maxpri=10]
      Thread[Reference Handler,10,system]
      Thread[Finalizer,8,system]
      Thread[Signal Dispatcher,9,system]
      Thread[Attach Listener,5,system]
      java.lang.ThreadGroup[name=main,maxpri=10]
          Thread[main,5,main]
          Thread[log4j mail appender,5,main]
  [DEBUG][2009-08-25 08:57:54,386] - isSuccess:false
  </code></pre>
  
  <p>I would like to know a systematic approach to figure out the reason. Thanks.</p>