split by new line java

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

Also in Java: