java - How to break line after every record in 2D araylist? -


hello have input file like-

item1;item2;item3 element1;emement2;element3 field1;field2;field3 

i want add elements input file 2d araylist not able break record after every row.

i coded like.

public class reader{ list<list<string>> file_column = new arraylist<list<string>>(); list<string> file_row = new arraylist<string>(); string cust_inputfile = "c:/inputfile.txt"; bufferedreader cust_br = new bufferedreader(new filereader(cust_inputfile)); while ((cust_line = cust_br.readline()) != null){         file_row.addall(cust_line);         file_column.add(cust_row); } system.out.println(file_column); } 

it gives following output-

[[item1;item2;item3, element1;emement2;element3,field1;field2;field3]] 

and want output like-

[[item1;item2;item3] [element1;emement2;element3] [field1;field2;field3]] 

please suggest necessary changes, in advance

you need move declaration:

list<string> file_row = new arraylist<string>(); 

inside while loop. add elements existing file_row. want new list each line.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -