-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
  • 2
  • 11

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
  • 387,369
  • 54
  • 702
  • 768
1
System.out.println(Arrays.toString(rows.toArray()));
Andrea
  • 6,032
  • 2
  • 28
  • 55
  • 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