From 78b379e2182284a7987dc36b3e4b4d6a7e19f467 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 10 Feb 2014 17:33:54 +0100 Subject: [PATCH] StringUtil.splitByLinesKeepSeparators javadoc --- .../com/intellij/openapi/util/text/StringUtil.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index dcb3697ac890..9ccaf0f9c14e 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -2222,6 +2222,20 @@ public class StringUtil extends StringUtilRt { return EOL_SPLIT_DONT_TRIM_PATTERN.split(string); } + /** + * Splits string by lines, keeping all line separators at the line ends and in the empty lines. + *
E.g. splitting text + *
+ * foo\r\n
+ * \n
+ * bar\n
+ * \r\n
+ * baz\r
+ * \r
+ *
+ * will return the following array: foo\r\n, \n, bar\n, \r\n, baz\r, \r + * + */ @NotNull public static String[] splitByLinesKeepSeparators(@NotNull String string) { return EOL_SPLIT_KEEP_SEPARATORS.split(string);