The codes:
String[] logs={"a","b","c"};
int errors=0;
for(String str:logs){
try{
LogParser.parse(str);
} catch(ParseException e){
error++;
continue; // Seems that, this two line codes are not reached.
}
}
In the above codes, the LogParser used to parse the tomcat log of combined pattern,when get the date format data, I use the SimpleDateFormat to parse it to a Java.Util.Date object, then it may throw a ParseException.the logs array here is just used for throwing the exception.
However when this exception ouccur while parsing one log, the app will exit ,I want it contine the next log.
How to make it?
I have read the tutorial at :
http://download.oracle.com/javase/tutorial/essential/exceptions/catchOrDeclare.html.
It said that the Error and RuntimeException are not subjec to the try catch block, the app will exit anyway.
But the java.text.ParseException extends the Exception,why it can not be subject to my try-catch block? Since the "error" variable do not be +1,
I have thought use this:
finally{
error++;
continue;
}
yes, it works,but when the log is correctly parsed,the error would be add also,it should not be.
Can any one tell me why?