KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > GetURL


1 import java.net.URL JavaDoc;
2 import java.io.InputStream JavaDoc;
3
4 public class GetURL {
5
6     public static void main( String JavaDoc argv[] ) throws Exception JavaDoc {
7
8         jcifs.Config.registerSmbURLHandler();
9
10         URL JavaDoc url = new URL JavaDoc( argv[0] );
11         InputStream JavaDoc in = url.openStream();
12
13         if( in != null ) {
14             byte[] buf = new byte[4096];
15             int n;
16             while(( n = in.read( buf )) != -1 ) {
17                 System.out.write( buf, 0, n );
18             }
19         } else {
20             System.out.println( "stream waz null" );
21         }
22         in.close();
23     }
24 }
25
26
Popular Tags