int thePort;
String theSite;
try {
theSite = args[0];
// trim trailing slash
if (theSite.endsWith("/")) {
theSite = theSite.substring(0, theSite.length()-1);
}
}
catch (Exception e) {
System.out.println(
"Usage: java Redirector http://www.newsite.com/ port");
return;
}
try {
thePort = Integer.parseInt(args[1]);
}
catch (Exception e) {
thePort = 80;
}
Thread t = new Thread(new Redirector(theSite, thePort));
t.start();