StringUtils { public static String replaceLFWithPreferredLineSeparator(String str) { return replaceLFWithPreferredLineSeparator(str, null); } private  StringUtils(); static String byteArrayToHex(byte[] array); static void appendHexFixedLength(char ch, StringBuilder result); static String emptyForNull(String str); static String stripSeperatorsFromEnd(String str); static String[] splitText(String text, String delimiters); static String[] splitLines(String text); static List<String> toLines(String output); static String[] splitBySpaces(String text); static String getTopMostClassName(String className); static String getResourceAsString(String resourcePath, Charset encoding); static String getOsLineSeparator(); static String replaceLFWithPreferredLineSeparator(String str); static String replaceLFWithPreferredLineSeparator(String str, Project ownerProject); static void writeStringToFile(String content, Charset encoding, Path file); static void writeStringToFile(String content, Charset encoding, File file); static int unescapedIndexOf(String str, int startIndex, char toFind); static String unescapeString(String str); static String[] unescapedSplit(String str, char splitChar); static String[] unescapedSplit(String str, char splitChar, int maxSplitCount); static String capitalizeFirstCharacter(String str); static List<String> splitArgs(String cmdLine); static final Collator STR_CMP; static final Charset UTF8; }
@Test public void testReplaceLFWithPreferredLineSeparator1() { String sep = System.getProperty("line.separator"); String str = "\nFirst Line\nSecond Line\nThird Line"; assertEquals(str.replace("\n", sep), StringUtils.replaceLFWithPreferredLineSeparator(str)); }
@Test public void testReplaceLFWithPreferredLineSeparator2() { assertEquals("", StringUtils.replaceLFWithPreferredLineSeparator("")); }