@Override public void close() throws IOException { delegate.close(); // no errors, overwrite the original file Files.move(temp, file); }
@Override public void close() throws IOException { delegate.close(); // if already closed, there should be no exception (see spec Closeable) if (temp.exists()) { Files.move(temp, file); } }
@Override public void close() throws IOException { delegate.close(); // if already closed, there should be no exception (see spec Closeable) if (temp.exists()) { Lock lock = lock(); try { // no errors, overwrite the original file Files.move(temp, actualFile); } finally { lock.release(); } } }
try { Files.move(temp, actualFile); } finally { lock.release();