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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:11:05+00:00 2026-05-23T10:11:05+00:00

OK.first i realized that readAll() saved the tokenized String in array index from 0

  • 0

OK.first i realized that readAll() saved the tokenized String in array index from 0 until it sees the newline char(next row of a csv file) and start again from 0.I want the tokenized String saved in a continuous array.

import au.com.bytecode.opencsv.CSVReader;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;

public class ReadTest {


    private static String data0 = "U:\\test-csv1.csv";
    private static String [] longArray = new String[50];
    private static String[] aString;
    private static List<String> longStr = new java.util.ArrayList<String>();
    private static int arrayCtr = 0;

    private static  void copyArray(String aTemp){

        longStr.add(arrayCtr, aTemp);
        System.out.println(arrayCtr);
        arrayCtr++;
        }

    private static void printElements(){

        for(int no =15;no<= 25;no++)
        System.out.print("\nelNo "+no+" is: "+longStr.get(no));
        System.out.println();
    }

    public static void main(String[] args) throws IOException {


    CSVReader reader1 = new CSVReader(new FileReader(data0),';');
    List aList;



        while ((aList = reader1.readAll())!= null){
            int outer= 0;
            String aTemp;
            String [] longArray = new String[50];

so here i make a loop to copy the tokenized String to be copied into a List called longStr.

            for (int counter= 0;counter <aList.size();counter++){
                String [] tempStr = (String[]) aList.get(counter);
                for (int j = 0; j < tempStr.length; j++){

                    aTemp = tempStr[j];
                    copyArray(aTemp);
                //  System.out.print(tempStr[j]);
                //  System.out.println();
                    System.out.print("strNo: " + j+"="+tempStr[j] + " "+"\n");
                    System.out.print("TEMP="+aTemp+"\n");


                }

this is a counter to obtain the num of row.

                System.out.println("loop for no. of element:"+(++outer));
                System.out.println();


                        printElements();
            }

printElements is a method to list down the elements in longStr.

I am having a problem in listing all the elements in longStr. This is what I have so far, I tried to arrange tokenized String from readAll() into continuous array as in longStr. When I tried to print out the elements after readAll() finished reading the csv file, it continuously print the elements from printElements() ie nonstop. How do I solve this, and where can I put the printElements() other than inside the while? I always get error like indexoutofbound if I place it somewhere else.

  • 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-23T10:11:06+00:00Added an answer on May 23, 2026 at 10:11 am

    I think

    while ((aList = reader1.readAll())!= null){
    

    is an endless loop. try

    if((aList = reader1.readAll())!= null){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting on my first large django project and have realized that the default
When I first moved from c to Java I thought that I've finished will
I have realized that my first question won't be answerable, since php can't deal
I have realized that there are 2 ways of running a dynamic string on
I've realised for the first time a couple of weeks ago that when setting
First let me say that I really feel directionless on this question. I am
First of all, I understand that it's unusual that I want to up-convert like
I just wrote my first OpenMP program that parallelizes a simple for loop. I
My company has new customers in Brazil and we realized that our excel reports
OK, I have my site going pretty well here: http://www.marioplanet.com But I've realized that

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.