title: How to atomically rename a file in Java, even if the dest file already exists?
body: <p>I have a cluster of machines, each running a Java app.</p>
  <p>These Java apps need to access a unique <code>resource.txt</code> file concurrently.</p>
  <p>I need to atomically rename a <code>temp.txt</code> file to <code>resource.txt</code> in Java, even if <code>resource.txt</code> already exist.</p>
  <p>Deleting <code>resource.txt</code> and renaming <code>temp.txt</code> doesn't work, as it's not atomic (it creates a small timeframe where <code>resource.txt</code> doesn't exist).</p>
  <p>And it should be cross-platform...</p>
  <p>Thanks !</p>