@Test public void stripCrLf() throws Exception { assertThat(Util.stripCrLf("")).isEqualTo(""); assertThat(Util.stripCrLf("\n\rtest\r\n")).isEqualTo("\\n\\rtest\\r\\n"); }
@Nonnull public static String stripCrLf(@Nonnull final String text) { final char[] src = text.toCharArray(); final StringBuilder dest = new StringBuilder(src.length + 10); for (final char ch : src) { switch (ch) { case 10: dest.append("\\n"); break; case 13: dest.append("\\r"); break; default: dest.append(ch); } } return dest.toString(); }
Util { @Nonnull public static String stripCrLf(@Nonnull final String text) { final char[] src = text.toCharArray(); final StringBuilder dest = new StringBuilder(src.length + 10); for (final char ch : src) { switch (ch) { case 10: dest.append("\\n"); break; case 13: dest.append("\\r"); break; default: dest.append(ch); } } return dest.toString(); } }
Util { @Nonnull public static String stripCrLf(@Nonnull final String text) { final char[] src = text.toCharArray(); final StringBuilder dest = new StringBuilder(src.length + 10); for (final char ch : src) { switch (ch) { case 10: dest.append("\\n"); break; case 13: dest.append("\\r"); break; default: dest.append(ch); } } return dest.toString(); }  }
Util { @Nonnull public static String stripCrLf(@Nonnull final String text) { final char[] src = text.toCharArray(); final StringBuilder dest = new StringBuilder(src.length + 10); for (final char ch : src) { switch (ch) { case 10: dest.append("\\n"); break; case 13: dest.append("\\r"); break; default: dest.append(ch); } } return dest.toString(); }  @Nonnull static String stripCrLf(@Nonnull final String text); @Nonnull static Class findRootEnclosingClass(@Nonnull final Class clazz); }
Util { @Nonnull public static String stripCrLf(@Nonnull final String text) { final char[] src = text.toCharArray(); final StringBuilder dest = new StringBuilder(src.length + 10); for (final char ch : src) { switch (ch) { case 10: dest.append("\\n"); break; case 13: dest.append("\\r"); break; default: dest.append(ch); } } return dest.toString(); }  @Nonnull static String stripCrLf(@Nonnull final String text); @Nonnull static Class findRootEnclosingClass(@Nonnull final Class clazz);  }