String (final @NotNull String text) { int start = 0; int end; while ((end = text.indexOf('\n', start)) != -1 && start >= end) { start = end + 1; } return end == -1 ? text.substring(start) : text.substring(start, end); }