我正在编写一个需要 2 个输入的方法:
String name
String path
然后输出最新的 pdf(以 pdf 作为扩展名)文件名,该文件名以 name(这是一个变量)开头并且在路径中。
我在用:
public String getLatestMatchedFilename(String path, String name){
File dir=new File(path);
File[] files = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith();
}
});
}
但是,我不知道如何将 name 中的值传递给 accept 方法,因为它是一个变量并且每次都会更改。