为了使用网络共享文件夹中的一些文件,我将迁移到 JCIFS。到目前为止,我已经做了以下测试来列出我需要的文件(取自这个例子)
public class ListDirectoryContent extends DosFileFilter {
int count = 0;
public ListDirectoryContent() {
super("*.txt", 0xFFFF);
}
public ListDirectoryContent(String wildcard, int attributes) {
super(wildcard, attributes);
}
public boolean accept(SmbFile file) throws SmbException {
System.out.print( " " + file.getName() );
count++;
return (file.getAttributes() & attributes) != 0;
}
public static void main( String[] argv ) throws Exception {
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("DOMAIN","myuser","A good password, yes sir!");
SmbFile file = new SmbFile( "smb://networkResource/sharedFolder/Files/SubFolderOne/", auth);
ListDirectoryContent llf = new ListDirectoryContent();
long t1 = System.currentTimeMillis();
SmbFile[] pepe = file.listFiles(llf);
long t2 = System.currentTimeMillis() - t1;
System.out.println();
System.out.println( llf.count + " files in " + t2 + "ms" );
System.out.println();
System.out.println( pepe.length + " SmbFiles in " + t2 + "ms" );
}
}
到目前为止,它适用于一个扩展通配符。如何扩大 dosfilefilter 以检查一组扩展?(就像 commons.io.FileUtils 一样)