title: Files.move() in Java giving a FilesSystemException error because folder is "being used by another process," but it's not
body: <p>I want to move a single file to another folder, but I can't because <em>"it is being used by another process."</em> This is my code:</p>
  
  <pre><code>static File myFile = new File("C:\\filepath");
  static File myFolder = new File("C:\\folderpath");
  
  public static void main(String[] args) 
          throws IOException {
      fileMove();
  }
  
  public static void fileMove() 
          throws IOException {
      Files.move(myFile.toPath(), myFolder.toPath(), StandardCopyOption.REPLACE_EXISTING);
      return;
  }
  </code></pre>
  
  <p>Error message:<br/>
  <strong>Exception in thread "main" java.nio.file.FileSystemException: C:\folderpath: The process cannot access the file because it is being used by another process.</strong></p>
  
  <p>I've tried out different files, different folders, but everytime it says the file is being used. I've tested it with a basic text file that was definitely closed and not being used when I tested it, but I still get the error. Does anyone know what's going on? Or, is there another way to move files that won't have this issue?</p>