您的位置:首页 > 编程语言 > Java开发

Set And Get Attribute --- DOS

2013-12-30 15:38 253 查看
定义路径
Path path = Paths.get("F:/cn/icer/ws/client/Business.java");


设置属性值
//setting the hidden attribute to true
try {
Files.setAttribute(path, "dos:hidden", true, LinkOption.NOFOLLOW_LINKS);
} catch (Exception e) {
e.printStackTrace();
}


获取属性值
//getting the hidden attribute
try {
boolean hidden = (boolean) Files.getAttribute(path, "dos:hidden", LinkOption.NOFOLLOW_LINKS);
System.out.println("Is hidden ? " + hidden);
} catch (Exception e) {
e.printStackTrace();
}


DOS属性可以用下面的名称来获得:
1) hidden
2) readonly
3) system
4) archive
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息