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 6329167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:36:10+00:00 2026-05-24T17:36:10+00:00

I have a vector which contains a list of files to open and parse,

  • 0

I have a vector which contains a list of files to open and parse, and I was wondering what is the best choice to do in my case.

This what I started to do :

for (int i =0 ; i< files.size() ; i++)
{
    System.out.println("n°" + i + " : " + files.elementAt(i));
    try
    {
        // open the files
    }
    catch (Exception e) {
    // TODO: handle exception
    }   
}

or what do you think about this one?

try
{
    for (int i =0 ; i< files.size() ; i++)
    {
        System.out.println("n°" + i + " : " + files.elementAt(i)); 
        // open the files       
    }
}
catch (Exception e) {
    // TODO: handle exception
}

EDIT:
My purpose is that, when I try to open a file that doesn’t exist I must throw something or maybe write the exception in a log file and continue opening the other files.

So I think the first solution is the best in my situation?

  • 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-24T17:36:11+00:00Added an answer on May 24, 2026 at 5:36 pm

    I would go with the first one – that way in case file 7 is corrupt for instance, you can still get the data from 8-10 (or whatever). And even if they are all corrupt, you don’t lose anything.

    I suppose it would come down to how your application should work. If one file being wrong will bring the whole thing to a screeching halt, the second is more appropriate, but generally I have found the first to be more useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 2D vector which contains objects. std::vector<std::vector<List> > ListPos; ListPos.clear(); std::vector<List> initPV;
I have a vector which contains a list of Hash maps in Clojure and
So I have a container(any kind, probably std::map or std::vector) which contains objects of
I have a 2D vector which contains the coordinates which I want to represent
I have a long vector x, and another v, which contains lengths. I would
I have a vector of characters which contains some words delimited by comma. I
So I have a list, each element of which is a numeric vector. Each
I have a vector, call it x, which contains very small numbers that I
I have a 640*480 vector which contains a set of numbers, I wish to
I have a vector of data, which contains integers in the range -20 20.

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.