1 2 3 Exception in thread "main" java.util.ConcurrentModificationException at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1493) at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1516) at IteratorErrorTest.main(IteratorErrorTest.java:14)
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
File[] listFiles(FilenameFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
Tests if a specified file should be included in a file list.
FileFilter接口方法
描述
boolean accept(File pathname)
Tests whether or not the specified abstract pathname should be included in a pathname list.
范围不同
File类对象使用FilenameFilter既可以过滤得到字符串数组,也可以得到File数组
方法
描述
String[] list(FilenameFilter filter)
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
File[] listFiles(FilenameFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
File类对象使用FileFilter只能得到File数组
方法
描述
File[] listFiles(FileFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.