- Files.readAttributes()
Path path = Paths.get("/home/icer/note.txt"); PosixFileAttributes attr = null; try { attr = Files.readAttributes(path, PosixFileAttributes.class); } catch (Exception e) { e.printStackTrace(); } System.out.println("File owner: " + attr.owner().getName()); System.out.println("File group: " + attr.group().getName()); System.out.println("File permissions: " + attr.permissions().toString());
- Files.getFileAttributeView().readAttributes()
Path path = Paths.get("/home/icer/note.txt"); PosixFileAttributes attr = null; try { attr = Files.getFileAttributeView(path, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); } catch (Exception e) { e.printStackTrace(); } System.out.println("File owner: " + attr.owner().getName()); System.out.println("
获取POSIX视图属性---POSIX
最新推荐文章于 2021-02-27 02:38:30 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)