Using FileChannel to fsync a directory with NIO.2

▼魔方 西西 提交于 2019-12-06 06:24:52

问题


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?


回答1:


See the following thread: http://mail.openjdk.java.net/pipermail/nio-dev/2015-May/003140.html

It was not technically supported, but looks like support will be retained as many applications rely on it.




回答2:


You can count on whatever the documentation says, and on nothing else.



来源:https://stackoverflow.com/questions/7694307/using-filechannel-to-fsync-a-directory-with-nio-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!