- 定义路径
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