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?
Add at the beginning to clear the list each time: