File: UrlReader.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 (41 lines) | stat: -rw-r--r-- 1,030 bytes parent folder | download | duplicates (8)
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
40
41
import java.net.*;
import java.io.*;

public class UrlReader extends Thread {

    URL url;
    byte[] buf;

    public UrlReader( String u, int bufsiz ) throws Exception {
        url = new URL( u );
        buf = new byte[bufsiz];
    }

    public void run() {
        try {
            InputStream in = url.openStream();
            int n;
            while ((n = in.read( buf )) > 0) {
                System.out.write( buf, 0, n );
            }
            in.close();
            System.err.println( url + " read complete" );
        } catch( Exception ex ) {
            ex.printStackTrace( System.err );
        }
    }

    public static void main( String[] args ) throws Exception {
        UrlReader[] readers = new UrlReader[args.length];

        jcifs.Config.registerSmbURLHandler();

        int i;
        for( i = 0; i < args.length; i++) {
            readers[i] = new UrlReader( args[i], (i + 1) * 128 );
        }
        for( i = 0; i < args.length; i++) {
            readers[i].start();
        }
    }
}