-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.

3
  • 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. Commented Aug 26, 2019 at 12:05
  • how about string.split(' IND,PAK,USA,AUS',',') Commented Aug 26, 2019 at 12:08
  • Possible duplicate of Java split string to array Commented Aug 26, 2019 at 14:12

1 Answer 1

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)
    );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.