代码如下
public class Demo2 {
public static void main(String[] args) {
//获取C盘目录下的隐藏文件
File file = new File("D:\\");
String[] s = file.list();
System.out.println(s.length);
File[] files = file.listFiles(new FileterByHidden());
for (int i = 0; i < files.length; i++) {
System.out.println(files[i]);
}
System.out.println(files.length);
}
}
class FileterByHidden implements FilenameFilter{
@Override
public boolean accept(File dir, String name) {
return (dir.isHidden());
}
}
|
|