本文整理汇总了Java中com.sun.nio.file.ExtendedOpenOption类的典型用法代码示例。如果您正苦于以下问题:Java ExtendedOpenOption类的具体用法?Java ExtendedOpenOption怎么用?Java ExtendedOpenOption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtendedOpenOption类属于com.sun.nio.file包,在下文中一共展示了ExtendedOpenOption类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFlags
import com.sun.nio.file.ExtendedOpenOption; //导入依赖的package包/类
static Flags toFlags(Set<? extends OpenOption> options) {
Flags flags = new Flags();
for (OpenOption option: options) {
if (option instanceof StandardOpenOption) {
switch ((StandardOpenOption)option) {
case READ : flags.read = true; break;
case WRITE : flags.write = true; break;
case APPEND : flags.append = true; break;
case TRUNCATE_EXISTING : flags.truncateExisting = true; break;
case CREATE : flags.create = true; break;
case CREATE_NEW : flags.createNew = true; break;
case DELETE_ON_CLOSE : flags.deleteOnClose = true; break;
case SPARSE : flags.sparse = true; break;
case SYNC : flags.sync = true; break;
case DSYNC : flags.dsync = true; break;
default: throw new UnsupportedOperationException();
}
continue;
}
if (option instanceof ExtendedOpenOption) {
switch ((ExtendedOpenOption)option) {
case NOSHARE_READ : flags.shareRead = false; break;
case NOSHARE_WRITE : flags.shareWrite = false; break;
case NOSHARE_DELETE : flags.shareDelete = false; break;
default: throw new UnsupportedOperationException();
}
continue;
}
if (option == LinkOption.NOFOLLOW_LINKS) {
flags.noFollowLinks = true;
continue;
}
if (option == OPEN_REPARSE_POINT) {
flags.openReparsePoint = true;
continue;
}
if (option == null)
throw new NullPointerException();
throw new UnsupportedOperationException();
}
return flags;
}