I need a to find file according to its name in directory tree. And then show a path to this file. I found something like this, but it search according extension. Could anybody h
You can use FileFilter Like this.
public class MyFileNameFilter implements FilenameFilter {
@Override
public boolean accept(File arg0, String arg1) {
// TODO Auto-generated method stub
boolean result =false;
if(arg1.startsWith("KB24"))
result = true;
return result;
}
}
And call it like this
File f = new File("C:\\WINDOWS");
String [] files = null;
if(f.isDirectory()) {
files = f.list(new MyFileNameFilter());
}
for(String s: files) {
System.out.print(s);
System.out.print("\t");
}