capturing ctrl-C exception
Hello -
I'm new to Java so maybe this is a basic question: how can I capture ctrl-C in my program?
I used the following code in main() but it doesn't seem to work:
try{
parseCmdline(args);
validateCmdline();
do{
line=getStatsLine(counter);
outputLine(line, counter);
sleepThd.sleep(interval * 1000);
...
}while (alive);
if (summarySet) outputSummary(titlesStr, counter);
}catch (Exception ex){
if (exinstanceof InterruptedException){
if (summarySet) outputSummary(titlesStr, counter);
System.exit(0);
}elseif (exinstanceof RuntimeException){
throw (RuntimeException) ex;
}
}
I need to be able to detect a ctrl-C to print out some information before exiting. Any help is appreciated.
Thanks.

