File: LargeListFiles.java

package info (click to toggle)
jcifs 1.3.16-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,856 kB
  • sloc: java: 23,124; xml: 3,663; ansic: 386; sh: 170; makefile: 26
file content (39 lines) | stat: -rw-r--r-- 1,067 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import jcifs.netbios.NbtAddress;
import jcifs.smb.*;
import java.util.Date;

public class LargeListFiles extends DosFileFilter {

    int count = 0;

    public LargeListFiles() {
        super("*", 0xFFFF);
    }
    public LargeListFiles(String wildcard, int attributes) {
        super(wildcard, attributes);
    }

    public boolean accept(SmbFile file) throws SmbException {
        System.out.print( " " + file.getName() );
        count++;
        return false; /* file processed here, tell listFiles() to discard */
    }

    public static void main( String[] argv ) throws Exception {
        if (argv.length < 1) {
            System.err.println("usage: LargeListFiles <smburl>\n");
            System.exit(1);
        }

        SmbFile file = new SmbFile( argv[0] );
        LargeListFiles llf = new LargeListFiles();

        long t1 = System.currentTimeMillis();
        file.listFiles(llf);
        long t2 = System.currentTimeMillis() - t1;

        System.out.println();
        System.out.println( llf.count + " files in " + t2 + "ms" );
    }
}