-1

I am unable to get the comma separated values from the excel cell using java code.

I had tried using the following code also.

String [] items = commaSeparated.split("\\s*,\\s*");
List<String> container = Arrays.asList(items);

I want the output as a list like:

IND
PAK
USA
AUS

When the input is imported from the Excel cell as IND,PAK,USA,AUS.

Arnaud Claudel
  • 3,000
  • 19
  • 25
  • The context of your question doesn't seem to make sense. We'll need more code, like statements for reading the Excel file and the contents of that Excel cell. – Max Voisard Aug 26 '19 at 12:05
  • how about string.split(' IND,PAK,USA,AUS',',') – bananas Aug 26 '19 at 12:08
  • Possible duplicate of [Java split string to array](https://stackoverflow.com/questions/14414582/java-split-string-to-array) – JeffC Aug 26 '19 at 14:12

1 Answers1

0

If all you want to do is print each item of your CSV data on a new line, this code will do the job.

    String csvLine = "IND,PAK,USA,AUS";
    Arrays.stream(csvLine.split(",")).forEach(
            item -> System.out.println(item)
    );
Thomas Martin
  • 678
  • 8
  • 19