对隐藏文件执行此操作:
File root = new File(yourDirectory);File[] files = root.listFiles(new FileFilter() { @Override public boolean accept(File file) { return !file.isHidden(); }});这不会返回隐藏文件。
对于系统文件,我认为这是Windows概念,因此
File尝试独立于系统的接口可能不支持该文件。但是,您可以使用命令行命令(如果存在)。
或使用@Reimeus的答案。
可能喜欢
File root = new File("C:\"); File[] files = root.listFiles(new FileFilter() { @Override public boolean accept(File file) { Path path = Paths.get(file.getAbsolutePath()); DosFileAttributes dfa; try { dfa = Files.readAttributes(path, DosFileAttributes.class); } catch (IOException e) { // bad practice return false; } return (!dfa.isHidden() && !dfa.isSystem()); } });DosFileAttributes是Java
7中引入的。



