我想列出某些类型的文件并写道:
File[] imageFiles = srcDir.listFiles({ File file -> file().name.endsWith("Artboard1ldpi.png") || file().name.endsWith("Artboard1mdpi.png") || file().name.endsWith("Artboard1hdpi.png") || file().name.endsWith("Artboard1xhdpi.png") || file().name.endsWith("Artboard1xxhdpi.png") || file().name.endsWith("Artboard1xxxhdpi.png") })
不幸的是,我收到以下错误:
> Ambiguous method overloading for method java.io.File#listFiles. Cannot resolve which method to invoke for [class CLOSURENAME] due to overlapping prototypes between: [interface java.io.FileFilter] [interface java.io.FilenameFilter]
如何提示Groovy,有什么选择?
File[] imageFiles = srcDir.listFiles({ File file -> file.name.endsWith("Artboard1ldpi.png") || file.name.endsWith("Artboard1mdpi.png") || file.name.endsWith("Artboard1hdpi.png") || file.name.endsWith("Artboard1xhdpi.png") || file.name.endsWith("Artboard1xxhdpi.png") || file.name.endsWith("Artboard1xxxhdpi.png") } as FileFilter)