java using stream split filter out newlines code example Example: split by new line java String lines[] = string.split("\\r?\\n");