1 import java.net.*; 2 import java.io.*; 3 4 public class UrlReader extends Thread { 5 6 URL url; 7 byte[] buf; 8 9 public UrlReader( String u, int bufsiz ) throws Exception { 10 url = new URL( u ); 11 buf = new byte[bufsiz]; 12 } 13 14 public void run() { 15 try { 16 InputStream in = url.openStream(); 17 int n; 18 while ((n = in.read( buf )) > 0) { 19 System.out.write( buf, 0, n ); 20 } 21 in.close(); 22 System.err.println( url + " read complete" ); 23 } catch( Exception ex ) { 24 ex.printStackTrace( System.err ); 25 } 26 } 27 28 public static void main( String [] args ) throws Exception { 29 UrlReader[] readers = new UrlReader[args.length]; 30 31 jcifs.Config.registerSmbURLHandler(); 32 33 int i; 34 for( i = 0; i < args.length; i++) { 35 readers[i] = new UrlReader( args[i], (i + 1) * 128 ); 36 } 37 for( i = 0; i < args.length; i++) { 38 readers[i].start(); 39 } 40 } 41 } 42 | Popular Tags |