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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:42:48+00:00 2026-05-23T16:42:48+00:00

private List<String> longStr = new java.util.ArrayList<String>(); private List aList = null; private String []

  • 0
private List<String> longStr = new java.util.ArrayList<String>();
private List aList = null;
private String [] noRow = null;
private static int arrayCtr = 0;

try {
CSVReader reader1 = new CSVReader(new   FileReader(inputFilePath),';');
    if((aList = reader1.readAll())!= null){
int outer= 0;
String aTemp;
for (int counter= 0;counter <aList.size();counter++){
       noRow = (String[]) aList.get(counter);
       for (int j = 0; j < noRow.length; j++){
        aTemp = noRow[j];
        copyArray(aTemp);
       }

    private int copyArray(String aTemp){
    longStr.add(arrayCtr, aTemp);
    //System.out.println(arrayCtr);
    arrayCtr++;
    return arrayCtr;
}

from the extract,every String from aList will be copied into noRow array->aTemp->longStr List.I integrated this function with JButton called “read”.everytime I clicked the button for diff files as an input,strings will be added continuously ie not generating new List for each diff files.for eg if a file has one element,this will be copied finally into longStr thus index will be 0,but if a diff file has 4 elements,this will be added to index no 1 and so on instead from starting from 0 again.what did i miss here?and how can i remove all elements in the longStr List after each jbutton event?

  • 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-23T16:42:49+00:00Added an answer on May 23, 2026 at 4:42 pm

    Add at the beginning to clear the list each time:

    longStr.clear();
    arrayCtr = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private List<String> subList; private List<List<String>> records = new ArrayList<List<String>>(); for(....){ subList = new ArrayList<String>();
private List<string> _S3 = new List<string>(); public string S3[int index] { get { return
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
@XmlRootElement(name = toplist) class toplist { private String description; private List<Item> items= new ArrayList<Item>();
Given a generic class: class MyClass ( private List l = new LinkedList <String>();
I have a class like this public SomeClass { private List<string> _strings = new
OK, so here is my ArrayList : private List<ClientThread> clients = new ArrayList<ClientThread>(); and
public class Main { public static void main(String args[]) { List list = new
Source Code of LoginAction.java package com.test; import java.util.ArrayList; import java.util.List; public class LoginAction {
Say you have the following java bean: public class MyBean { private List<String> names

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.