FileDocCategorySizeDatePackage
SourceViewer.javaAPI DocExample807Sat Sep 09 19:54:54 BST 2000None

SourceViewer.java

import java.net.*;
import java.io.*;

public class SourceViewer {

  public static void main (String args[]) {

    if  (args.length > 0) {
      try {
        //Open the URL for reading
        URL u = new URL(args[0]);
        InputStream in = u.openStream();
        // buffer the input to increase performance 
        in = new BufferedInputStream(in);       
        // chain the InputStream to a Reader
        Reader r = new InputStreamReader(in);
        int c;
        while ((c = r.read()) != -1) {
          System.out.print((char) c);
        } 
      }
      catch (MalformedURLException e) {
        System.err.println(args[0] + " is not a parseable URL");
      }
      catch (IOException e) {
        System.err.println(e);
      }

    } //  end if

  } // end main

}  // end SourceViewer