0

1.

name Jo Bloggs
birthday 08-07-1900
phone 88884444
address 9001 Chester Crescent, Chatswood, NSW 2057

email michael@fanfare.com.au
name Michael Willianm
birthday 01-4-1950
address 37 Barton Ave, Haberfield, NSW 2045
phone 19876245

name Linda Evans
birthday 22-02-1996
phone 135625
email l.evans@gmail.com
address 119 Gibbes St, Rockdale, NSW 2216

2.How can I split these Two strings by empty lines? Here is the code I wrote. string Contains these strings, I want to use a array to store these three strings.

String str[] = string.toString().split("\n\r");

/*string = the three strings I gave in 1. part */

Thiyagu
  • 17,362
  • 5
  • 42
  • 79
Jay Park
  • 308
  • 1
  • 6
  • 14

1 Answers1

1

Each of the blocks of info are separated by two \ns. Hence, you can use \n\n.

String[] arr = string.split("\n\n");
Thiyagu
  • 17,362
  • 5
  • 42
  • 79