KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > LargeListFiles


1 import jcifs.netbios.NbtAddress;
2 import jcifs.smb.*;
3 import java.util.Date JavaDoc;
4
5 public class LargeListFiles extends DosFileFilter {
6
7     int count = 0;
8
9     public LargeListFiles() {
10         super("*", 0xFFFF);
11     }
12     public LargeListFiles(String JavaDoc wildcard, int attributes) {
13         super(wildcard, attributes);
14     }
15
16     public boolean accept(SmbFile file) throws SmbException {
17         System.out.print( " " + file.getName() );
18         count++;
19         return false; /* file processed here, tell listFiles() to discard */
20     }
21
22     public static void main( String JavaDoc[] argv ) throws Exception JavaDoc {
23         if (argv.length < 1) {
24             System.err.println("usage: LargeListFiles <smburl>\n");
25             System.exit(1);
26         }
27
28         SmbFile file = new SmbFile( argv[0] );
29         LargeListFiles llf = new LargeListFiles();
30
31         long t1 = System.currentTimeMillis();
32         file.listFiles(llf);
33         long t2 = System.currentTimeMillis() - t1;
34
35         System.out.println();
36         System.out.println( llf.count + " files in " + t2 + "ms" );
37     }
38 }
39
40
Popular Tags