title: Why would a file rename fail in java
body: <p>I have the following snippet of java code:</p>
  
  <pre><code>File directoryToMoveTo = new File(file.getParent()+"_TEMP");
  boolean success = file.renameTo(new File(directoryToMoveTo,file.getName()));
  if (!success){
      logger.warn("Failed to move [%s] to temp Directory.");
  }
  </code></pre>
  
  <p>file is passed in as an argument to the method and is one of an array of files obtained like this:</p>
  
  <pre><code>File[] files = directory.listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
          logger.debug(String.format("Testing file [%s]",name));
          boolean passed = name.endsWith(getFileDescription().getFilePattern());
          logger.debug(String.format("Passed [%s]",passed));
          return passed;
      }
  });
  </code></pre>
  
  <p>Why would success by false in the first snippet?</p>
  
  <p>I tried this code in isolation on a different file and it seems to work.</p>