-1

I've got such list:

List<String[]> rows = new CsvParser(settings).parseAll(new File("Z:/FV 18001325.csv"), "UTF-8");

What's the simplest way to print them to console?

I've tried

System.out.println(Arrays.toString(rows));

And also:

String joined = String.join(",", rows);
System.out.println(joined); 

But no use...

n0rek
  • 90
  • 1
  • 1
  • 9

2 Answers2

5

The code of the other answer would print something like:

[[Ljava.lang.String;@4c873330, [Ljava.lang.String;@119d7047]

What you need is either:

rows.forEach(arr -> System.out.println(Arrays.toString(arr)));

which would print the output like this:

[a, b, c]
[d, e, f]

or

System.out.println(Arrays.deepToString(rows.toArray()));

which would print the output like this:

[[a, b, c], [d, e, f]]
Eran
  • 374,785
  • 51
  • 663
  • 734
1
System.out.println(Arrays.toString(rows.toArray()));
Andrea
  • 5,893
  • 1
  • 29
  • 53
  • Didn't you find the answer [here](https://stackoverflow.com/a/10168400/1100080)? If that is the case please reference to that answer – Arion Mar 20 '18 at 15:08
  • This will not print the desired output since it will call `toString()` on each array in the list. Use `Arrays.deepToString()` instead. – O.O.Balance Mar 20 '18 at 15:22