通过调用Files.getAttribute()方法找出组
import java.io.IOException; import java.nio.file.Files; /** from 时 代 J a v a**/ import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.GroupPrincipal; public class Main { public static void main(String[] args) { Path path = Paths.get("/home/folder1/folder2/folder3/test.txt"); try { GroupPrincipal group = (GroupPrincipal) Files.getAttribute(path, "posix:group", LinkOption.NOFOLLOW_LINKS);/**来 自 时代Java - N o w J a v