-6

If I have an input of

this is a string
this is also a string
i am a string

can i store them in an array like

[0] this is a string
[1] this is also a string
[2] i am a string

If so, how can I achieve this kind of output?

needhelp
  • 1
  • 1

1 Answers1

3

You could use:

String[] output = input.split"\\r?\\n");

That would split the lines if \r\n or \n is used for line breaks.

Rob Obdeijn
  • 253
  • 2
  • 9