3

Docs for File.renameTo() say: "Many aspects of the behavior of this method are inherently platform-dependent: The rename (...) might not be atomic..."

That is pretty vague and I need disambiguation. Is this method atomic in Oracle Java 6 on WinXP and newer?

Konrad Garus
  • 53,145
  • 43
  • 157
  • 230
  • I suspect it depends on whether you are renaming a file in a directory, moving a file around a file system or moving a file between file systems (which is a copy and a delete) – Peter Lawrey Nov 18 '11 at 15:03

2 Answers2

4

Based on this answerxpost

"Win32 does not guarantee atomic file meta data operations. I'd provide a citation, but there is none - that fact that there's no written or documented guarantee means as much"

No.

Community
  • 1
  • 1
Woot4Moo
  • 23,987
  • 16
  • 94
  • 151
4

Since win32 historically didn't provide any support for atomic file moves/renames, that's highly unlikely.

They added functions for this with Vista, so the new file functions in Java7 may actually use those - no idea. But for XP you're out of luck.

Voo
  • 29,040
  • 11
  • 82
  • 156