Reputation: 147
@ Gouki Pls check if this is a correct Implementation as there may be multiple attributes in my row that has T,N or X -I basically want to check if the first attribute in every row for a value of T,N or X and do some business logic- Thanks
public void printarray(List<String[]> usersList) {
for(String[] row: usersList) {
System.out.println(row[0]);
if(row[0].equals("N")){
System.out.println("Insert records in DB");
System.out.println("*********************");
System.out.println(row[1]+" , " + row[2]+" , "+row[3]+" , " + row[4]+" " +row[5]);
}
if(row[0].equals("T")){
System.out.println("Get date from DB and update DB based on the same");
System.out.println("*********************");
System.out.println(row[1]+" , " + row[2]+" , "+row[3]+" , " + row[4]+" " +row[5]);
}
if(row[0].equals("X")){
System.out.println("Update 2 sub tables");
System.out.println("*********************");
System.out.println(row[1]+" , " + row[2]+" , "+row[3]+" , " + row[4]+" " +row[5]);
}
}
}
Upvotes: 0
Views: 928
Reputation: 4402
You can perhaps use a List as container for every row (which is an array).
List<String[]> userList = new ArrayList<String[]>();
and then on your while loop:
while ((line = br.readLine()) != null) {
String[] values = line.split(",");
userList.add(values);
}
To retrieve, modify your printarray :
public void printarray(List<String[]> usersList)
{
for(String[] row: usersList) {
for(String element:row) {
System.out.println(element);
}
}
System.out.println();
}
Upvotes: 4