FileDocCategorySizeDatePackage
SecureSourceViewer.javaAPI DocExample1142Sat Sep 09 19:54:46 BST 2000None

SecureSourceViewer.java

import java.net.*;
import java.io.*;
import com.macfaq.net.DialogAuthenticator;


public class SecureSourceViewer {

  public static void main (String args[]) {

    Authenticator.setDefault(new DialogAuthenticator());

    for (int i = 0; i < args.length; i++) {
      
      try {
        //Open the URL for reading
        URL u = new URL(args[i]);
        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) {
        e.printStackTrace();
        System.err.println(e);
      }
      
      // print a blank line to separate pages
      System.out.println();
      
    } //  end for
  
    // Since we used the AWT, we have to explicitly exit.
    System.exit(0);

  } // end main

}  // end SecureSourceViewer