1 import jcifs.netbios.NbtAddress; 2 import jcifs.smb.*; 3 import java.util.Date ; 4 5 public class FilterFiles { 6 7 static class ShortFilenameFilter implements SmbFilenameFilter { 8 public boolean accept( SmbFile dir, String name ) throws SmbException { 9 return name.length() < 14; 10 } 11 } 12 static class BigFileFilter implements SmbFileFilter { 13 public boolean accept( SmbFile file ) throws SmbException { 14 return file.length() > 0x1FFFFL; 15 } 16 } 17 18 public static void main( String [] argv ) throws Exception { 19 20 SmbFile file = new SmbFile( argv[0] ); 21 BigFileFilter filter = new BigFileFilter(); 22 ShortFilenameFilter sfilter = new ShortFilenameFilter(); 23 DosFileFilter everything = new DosFileFilter( "*", 0xFFFF ); 24 25 long t1 = System.currentTimeMillis(); 26 SmbFile[] files = file.listFiles( everything ); 27 long t2 = System.currentTimeMillis() - t1; 28 29 for( int i = 0; i < files.length; i++ ) { 30 System.out.print( " " + files[i].getName() ); 31 } 32 System.out.println(); 33 System.out.println( files.length + " files in " + t2 + "ms" ); 34 } 35 } 36 37 | Popular Tags |