调用Files.isHidden()方法。
import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path;//时代Java公众号 public class Main { public static void main(String[] args) { Path path = FileSystems.getDefault().getPath( "C:/folder1/folder2/folder4", "my.txt"); try { boolean is_hidden = Files.isHidden(path); System.out.println("Is hidden ? " + is_hidden); } catch (IOException e) { System.err.println(e); } } }