title: Chose file name with Files.copy()
body: <p>I have a temp file in <code>/tmp</code> that I want to archive somewhere so I tried:</p>
  
  <pre><code>import java.nio.file.Files;
  [...]
  
  Path source = Paths.get("/tmp/path/to/file_123456789.xml");
  Path destination = Paths.get("/path/to/archive/dir/file.xml");
  Files.copy(source, destination).
  </code></pre>
  
  <p>This fails because :</p>
  
  <blockquote>
    <p>/path/to/archive/dir/file.xml is not a directory</p>
  </blockquote>
  
  <p>I know it! But I just want to chose the destination file's name.</p>
  
  <p>Up to now, I have some solutions which do not satisfy me:</p>
  
  <ul>
  <li>Create a temp directory with <code>Files.createTempDirectory</code> then move the temp file in it, rename it then move it to the destination directory.</li>
  <li>Copy the temp file in the archive directory then rename it there. But if the rename fails, I have some junk in the archive directory.</li>
  <li>Create an empty file in the archive directory and manually copy the content of the source file in it.</li>
  </ul>
  
  <p>A cleaner solution probably exists. Do you know it?</p>