Split Java String by New Line

This should cover you:

String lines[] = string.split("\\r?\\n");

There’s only really two newlines (UNIX and Windows) that you need to worry about.

Leave a Comment