I just discovered that with NIO.2, at least under Linux, I can open a FileChannel
on a directory, and calling force(true) calls fsync()
on the underlying file descriptor. Without getting into whether this should be necessary, it's nice to finally have this functionality available in pure Java.
I haven't been able to find anywhere that this behaviour is documented, though. Can I count on this working on all Unix platforms, in future versions of Java, and in non-Oracle JVMs?