/*
* Author : Deepak Singh Bisht
*/
package com.infogain.adapter.cgui;
import java.io.*;
public class CGUIInvokeBrowser
{
// The default system browser under windows.
private static final String WIN_PATH = "rundll32";
// The flag to display a url.
private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
/**
* Display provided URL in systems default browser
* @param String url.
*/
public static void displayURL(String url)throws Exception
{
boolean windows = isWindowsPlatform();
String cmd = null;
try
{
if (windows)
{
cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
Process p = Runtime.getRuntime().exec(cmd);
}
}
catch(IOException x)
{
// couldn't exec browser
throw new Exception("Could not invoke browser, command=" + cmd);
}
}
/**
* Check if the current OS is windows platform.
* @return boolean.
*/
public static boolean isWindowsPlatform()
{
String os = System.getProperty("os.name"

;
if ( os != null && os.startsWith("Windows"

)
return true;
else
return false;
}
}