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

  • Home
  • SEARCH
  • 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 6726677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:57:19+00:00 2026-05-26T09:57:19+00:00

I have a CSV file. It has many lines. In each line there are

  • 0

I have a CSV file. It has many lines. In each line there are multiple values separated by commas.

I am using OPENCSV to extract data from the file. I want to have the ability to directly go to any particular line which is in List data structure.

CSVReader reader = new CSVReader(new FileReader(
                    "myfile.csv"));
            try {
                List<String[]> myEntries = reader.readAll();
                for (String[] s : myEntries) {
                    System.out.println("Next item: " + s);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

This prints

Next item: [Ljava.lang.String;@6c8b058b
Next item: [Ljava.lang.String;@1b192059
Next item: [Ljava.lang.String;@e9ac0f5
Next item: [Ljava.lang.String;@51f21c50
Next item: [Ljava.lang.String;@6e20f237
Next item: [Ljava.lang.String;@34fe315d
Next item: [Ljava.lang.String;@1c5aebd9
Next item: [Ljava.lang.String;@1532021a
Next item: [Ljava.lang.String;@62803d5
Next item: [Ljava.lang.String;@2d13981b
Next item: [Ljava.lang.String;@61672bbb

I want to know if there is anyway I could access individual lines, elements via List.

i.e

    1,2,3,4,5
    6,7,8,9,10
    11,12,13,14
    15,16,17,18

I want String[] nextLine = 1,2,3,4,5 (where nextLine[0] = 1 nextLine[1] = 2 etc) and in the next iteration nextLine should be 6,7,8,9,10 etc

  • 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-26T09:57:19+00:00Added an answer on May 26, 2026 at 9:57 am

    The List interface supports random access via the get method – to get line 0, use list.get(0). You’ll need to use array access on that, ie, lines.get(0)[0] is the first element of the first line.

    See the javadoc here.

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

Sidebar

Related Questions

I have a CSV file with several entries, and each entry has 2 unix
In short, I have a 20,000,000 line csv file that has different row lengths.
I have a csv file that looks something like this (actual file has many
I have a csv file that has column values enclosed within double quotes. I
I have a csv file into which has crept some ^M dos line ends,
I have a CSV file that has lists of values for some fields. They're
I have a csv file which has a word for each row like this
I have a csv file that has 2 columns separated by a comma -
I have a CSV file. Each line is made up of the same format
I have two csv file. First File has date offerid clicks orders Second File

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.