-
Notifications
You must be signed in to change notification settings - Fork 1
/
UrlReader.java
41 lines (34 loc) · 1.01 KB
/
UrlReader.java
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();
}
}
}