Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3273316
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:55:09+00:00 2026-05-17T18:55:09+00:00

The codes: String[] logs={a,b,c}; int errors=0; for(String str:logs){ try{ LogParser.parse(str); } catch(ParseException e){ error++;

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:55:09+00:00Added an answer on May 17, 2026 at 6:55 pm

    You are catching ParseException, but probably another exception type is thrown. Try to replace this with (Exception e) and see what type you’re throwing. Then you can reduce the scope of the catch to the appropriate exception type.

    String[] logs={"a","b","c"};
    int errors=0;
    for(String str:logs){
      try{
        LogParser.parse(str);
      } catch(Exception e){ // <-- try this
        error++;
        continue;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of string with special escape codes that I want to
I'm trying to create a string array with lines of codes, so that the
Code: String message = MessageFormat.format(error {0},e); E.g. message: java.text.ParseException: Unparseable date: sdf sf sa
I've made my Logger, that logs a string, a static class with a static
I have this method that logs errors from the Silverlight client: [MethodImpl(MethodImplOptions.NoInlining)] public static
Apart from error codes, error strings and logs, are there any other features which
I've tried some codes like string s = this is example; txt1TextBlock.Text = Thread.CurrentCulture.TextInfo.ToTitleCase(s);
I'm trying to find aiport codes given a string like (JFK) or [FRA] using
I want to store a list of binary codes in a String[] array, such
I can use the following codes to trim a string: -(void) aMethod { //

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.