Java Reference
In-Depth Information
{
while (true)
{
System.out.println(
"Checking " + url + " at " + (new Date()));
// try to connect
try
{
URLConnection http = url.openConnection();
http.connect();
System.out.println("The site is up.");
} catch (IOException e1)
{
System.out.println("The site is down!!!");
}
// now wait for a minute before checking again
try
{
Thread.sleep(60000);
} catch (InterruptedException e)
{
}
}
}
/**
* Typical Java main method, create an object, and then
* start the object passing arguments. If insufficient
* arguments are provided, then display startup
* instructions.
*
* @param args Program arguments.
*/
public static void main(String args[])
{
try
{
if (args.length != 1)
{
System.out.println("Usage: MonitorSite [URL to Monitor]");
} else
{
MonitorSite d = new MonitorSite();
d.monitor(new URL(args[0]));
Search WWH ::




Custom Search