package ir.utilities;
import java.io.*;
import java.lang.*;

/** 
 * Utilities for displaying a URL or local file in the current Netscape
 * window using "netscape -remote".  User must have netscape running.
 *
 * @author Ray Mooney
*/

public class Netscape
{
    /** Make netscape display a given URL */
    public static void display(String file) {
	String[] cmd = new String[2];

	// cmd position 0 contains the absolute file name for wordpad.exe 
	// on your machine.
	cmd[0] = "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe";

	// cmd position 1 contains the absolute name of the file you wish
	// to open---there are spaces preceding the file name
	cmd[1] = file ;

	try {
	    Runtime.getRuntime().exec(cmd);
	}
	catch (IOException e) {
	    System.out.println("Unable to run the remote process.");
		}
    }

    /** Make netscape display a given file */
    public static void display(File file)  {
	display(file.getAbsolutePath());
    }

    /** Test interface */
    public static void main(String[] args) throws IOException {
	String name = args[0];
	File file = new File(name);
	System.out.println("\nDisplaying: " + file.getAbsolutePath());
	display(file);
    }

}
