本文整理汇总了Java中java.nio.file.attribute.DosFileAttributeView.setHidden方法的典型用法代码示例。如果您正苦于以下问题:Java DosFileAttributeView.setHidden方法的具体用法?Java DosFileAttributeView.setHidden怎么用?Java DosFileAttributeView.setHidden使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.attribute.DosFileAttributeView
的用法示例。
在下文中一共展示了DosFileAttributeView.setHidden方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSetGetHidden
import java.nio.file.attribute.DosFileAttributeView; //导入方法依赖的package包/类
@Test
public void testSetGetHidden() throws Exception {
for(Path path : Arrays.asList(
Files.createDirectory(root.resolve("dir")),
Files.createFile(root.resolve("file")))) {
DosFileAttributes attributes = Files.readAttributes(path, DosFileAttributes.class);
assertFalse(attributes.isHidden());
DosFileAttributeView view = Files.getFileAttributeView(path, DosFileAttributeView.class);
view.setHidden(true);
attributes = Files.readAttributes(path, DosFileAttributes.class);
assertTrue(attributes.isHidden());
}
}
示例2: setPermissions
import java.nio.file.attribute.DosFileAttributeView; //导入方法依赖的package包/类
public static void setPermissions(Context context, Path file, String permissions) {
DosFileAttributeView fileAttributeView = Files.getFileAttributeView(file, DosFileAttributeView.class);
try {
fileAttributeView.setArchive(permissions.contains("A"));
fileAttributeView.setHidden(permissions.contains("H"));
fileAttributeView.setReadOnly(permissions.contains("R"));
fileAttributeView.setSystem(permissions.contains("S"));
} catch (IOException ex) {
Logger.error("Error setting permissions for '" + file + "'", ex, context.isDisplayStackTrace());
}
}
示例3: testView
import java.nio.file.attribute.DosFileAttributeView; //导入方法依赖的package包/类
@Test
public void testView() throws IOException {
DosFileAttributeView view =
provider.view(
fileLookup(),
ImmutableMap.<String, FileAttributeView>of(
"basic", new BasicAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
assertNotNull(view);
assertThat(view.name()).isEqualTo("dos");
DosFileAttributes attrs = view.readAttributes();
assertThat(attrs.isHidden()).isFalse();
assertThat(attrs.isArchive()).isFalse();
assertThat(attrs.isReadOnly()).isFalse();
assertThat(attrs.isSystem()).isFalse();
view.setArchive(true);
view.setReadOnly(true);
view.setHidden(true);
view.setSystem(false);
assertThat(attrs.isHidden()).isFalse();
assertThat(attrs.isArchive()).isFalse();
assertThat(attrs.isReadOnly()).isFalse();
attrs = view.readAttributes();
assertThat(attrs.isHidden()).isTrue();
assertThat(attrs.isArchive()).isTrue();
assertThat(attrs.isReadOnly()).isTrue();
assertThat(attrs.isSystem()).isFalse();
view.setTimes(FileTime.fromMillis(0L), null, null);
assertThat(view.readAttributes().lastModifiedTime()).isEqualTo(FileTime.fromMillis(0L));
}