使用FileChannel与NIO.2同步目录 [英] Using FileChannel to fsync a directory with NIO.2

查看:112
本文介绍了使用FileChannel与NIO.2同步目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现,使用NIO.2,至少在Linux下,我可以在一个目录上打开一个 FileChannel ,然后调用 force(true)来电基础文件描述符上的fsync()。无需考虑是否需要 ,这很好最终在纯Java中提供此功能。

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.

但是,我无法找到记录此行为的任何地方。我可以指望在所有Unix平台,未来版本的Java和非Oracle JVM中工作吗?

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?

推荐答案

参见以下主题: 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.

这篇关于使用FileChannel与NIO.2同步目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆