Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
File[]listFiles(FileFilterfilter)
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[]listFiles(FilenameFilterfilter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
翻译:
listFiles()
返回表示此抽象路径名所表示的目录中的文件的抽象路径名数组。
File [] listFiles(FileFilter filter)
返回一个抽象路径名数组,表示此抽象路径名所指向的目录中满足指定过滤器的文件和目录。
File [] listFiles(FilenameFilter filter)
返回一个抽象路径名数组,表示此抽象路径名所指向的目录中满足指定过滤器的文件和目录。
示例:
public class myFileFilter implements FileFilter{
@Override
public boolean accept(File pathname) { //此处重写accept方法
String filename = pathname.getName().toLowerCase(); /*toLowerCase()将字符串中的字母全部改成小写*/
if(filename.contains(".txt")){
returnfalse;
}else{
returntrue;
}
}
}