title: How does one atomically replace a directory with another one in Java?
body: <p>I have a directory that contains data files served to clients, say, <code>/srv/data</code>. While making a series of updates, I am working on <code>/srv/data_tmp</code>, and at the end of the operation, I would like to atomically replace <code>data</code> with <code>data_tmp</code>. <code>File.renameTo()</code> always returns false for me when the destination is an existing directory. How can I do this?</p>