/** * This quick hack constructs the two html files for SunSphere.. * * Copyright &copy; 1996 Martin Minow. All Rights Reserved.<p> * World map copyright &copy; 1992-97 Apple Computer Inc. All Rights Reserved. * Used by permission.<p> * * Permission to use, copy, modify, and redistribute this software and its * documentation for personal, non-commercial use is hereby granted provided that * this copyright notice and appropriate documentation appears in all copies. This * software may not be distributed for fee or as part of commercial, "shareware," * and/or not-for-profit endevors including, but not limited to, CD-ROM collections, * online databases, and subscription services without specific license.<p> * * @author <a href="mailto:minow@pobox.com">Martin Minow</a> * @version 1.1 * This applet is Java 1.1 compatible. *///import com.apple.mrj.*;import java.awt.*;import java.awt.event.*;import java.util.*;import java.lang.*;import java.io.*;class Main extends Frame{    static final String		personalStart	= "<-- ++PERSONAL>";    static final String		personalEnd	= "<-- --PERSONAL>";    static final String		mrjStart	= "<-- ++MRJ>";    static final String		mrjEnd		= "<-- --MRJ>";                public static void main(	    String	    args[]	)    {    	Frame window		= new Frame("Make Documentation");	final Label label	= new Label("Run by MakeDocumentation.run");	window.add("South", label);	window.setSize(new Dimension(240, 90));	window.setVisible(true);	makeDocumentation(		"SunSphereHtml.txt",		"SunSphere.html",		"SunSphereMRJ.html",		label	    );	makeDocumentation(		"SunSphereInfoHtml.txt",		"SunSphereInfo.html",		"SunSphereInfoMRJ.html",		label	    );	System.exit(0);    }    public static void makeDocumentation(    	    String		sourceFile,    	    String		myOutputFileName,    	    String		mrjOutputFileName,    	    Label		label    	)    {	BufferedReader		in		= null;	PrintWriter		myOutput	= null;	PrintWriter		mrjOutput	= null;	boolean			myOutputOK	= true;	boolean			mrjOutputOK	= true;	// MRJFileUtils.setDefaultFileType("TEXT");	// MRJFileUtils.setDefaultFileCreator("WARZ");	label.setText("Processing " + sourceFile);    	try {    	    in			= new BufferedReader(new FileReader(sourceFile));    	}	catch (IOException e) {	    label.setText("Opening " + sourceFile + ": " + e.toString());	    System.err.println("Can't open " + sourceFile);	    System.err.println(e);	    waitForever();	    return;	}	try {	    myOutput		= new PrintWriter(new FileWriter(myOutputFileName));	}	catch (IOException e) {	    label.setText("Opening " + myOutputFileName + ": " + e.toString());	    System.err.println("Can't create " + myOutputFileName);	    System.err.println(e);	    waitForever();	    return;	}	try {	    mrjOutput		= new PrintWriter(new FileWriter(mrjOutputFileName));	}	catch (IOException e) {	    label.setText("Opening " + mrjOutputFileName + ": " + e.toString());	    System.err.println("Can't create " + mrjOutputFileName);	    System.err.println(e);	    waitForever();	    return;	}	int lineCount		= 0;	try {	    myOutputOK		= true;	    mrjOutputOK		= true;	    String text		= null;	    while ((text = in.readLine()) != null) {		++lineCount;		if (text.equals(personalStart)) {		    mrjOutputOK	= false;		    continue;		}		if (text.equals(mrjStart)) {		    myOutputOK	= false;		    continue;		}		if (text.equals(personalEnd)) {		    mrjOutputOK	= true;		    continue;		}		if (text.equals(mrjEnd)) {		    myOutputOK	= true;		    continue;		}		if (myOutputOK) {		    myOutput.println(text);		}		if (mrjOutputOK) {		    mrjOutput.println(text);		}	    }	}	catch (IOException e) {	    label.setText("Error processing files at line " + lineCount + e.toString());	    System.err.println("Can't process files: " + e);	    System.err.println("Failed at line " + lineCount);	}	label.setText("Finished files at line " + lineCount);	try {	    myOutput.close();	}	catch (Exception e) {	    label.setText("Can't close " + myOutputFileName  + e.toString());	    System.err.println("Can't close my Output: " + e);	}	try {	    mrjOutput.close();	}	catch (Exception e) {	    label.setText("Can't close " + mrjOutputFileName  + e.toString());	    System.err.println("Can't close MRJ output: " + e);	}	label.setText("All done after reading " + lineCount + " input lines");    }    public static void waitForever()    {	waitForever(60);    }    public static void waitForever(    	    int			duration    	)    {	try {	    Thread.sleep(duration * 1000);	}	catch (Exception e) {}    }}