@Test public void testControlCharacters() { String testString = "\b \t \n \f \r default"; String controlString = StringUtils.showControlCharacters(testString); assertEquals("\\b \\t \\n \\f \\r default", controlString); }
public static String showControlCharacters(String str) { int len = str.length(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i += 1) { char c = str.charAt(i); switch (c) { case '\b': sb.append("\\b"); break; case '\t': sb.append("\\t"); break; case '\n': sb.append("\\n"); break; case '\f': sb.append("\\f"); break; case '\r': sb.append("\\r"); break; default: sb.append(c); } } return sb.toString(); }
StringUtils { public static String showControlCharacters(String str) { int len = str.length(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i += 1) { char c = str.charAt(i); switch (c) { case '\b': sb.append("\\b"); break; case '\t': sb.append("\\t"); break; case '\n': sb.append("\\n"); break; case '\f': sb.append("\\f"); break; case '\r': sb.append("\\r"); break; default: sb.append(c); } } return sb.toString(); } }
StringUtils { public static String showControlCharacters(String str) { int len = str.length(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i += 1) { char c = str.charAt(i); switch (c) { case '\b': sb.append("\\b"); break; case '\t': sb.append("\\t"); break; case '\n': sb.append("\\n"); break; case '\f': sb.append("\\f"); break; case '\r': sb.append("\\r"); break; default: sb.append(c); } } return sb.toString(); } private  StringUtils(); }
StringUtils { public static String showControlCharacters(String str) { int len = str.length(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i += 1) { char c = str.charAt(i); switch (c) { case '\b': sb.append("\\b"); break; case '\t': sb.append("\\t"); break; case '\n': sb.append("\\n"); break; case '\f': sb.append("\\f"); break; case '\r': sb.append("\\r"); break; default: sb.append(c); } } return sb.toString(); } private  StringUtils(); static String byteToHexString(final byte[] bytes, final int start, final int end); static String byteToHexString(final byte[] bytes); static byte[] hexStringToByte(final String hex); static String arrayAwareToString(Object o); static String arrayToString(Object array); static String showControlCharacters(String str); static String getRandomString(Random rnd, int minLength, int maxLength); static String getRandomString(Random rnd, int minLength, int maxLength, char minValue, char maxValue); static String generateRandomAlphanumericString(Random rnd, int length); static void writeString(@Nonnull String str, DataOutputView out); static String readString(DataInputView in); static void writeNullableString(@Nullable String str, DataOutputView out); static @Nullable String readNullableString(DataInputView in); static boolean isNullOrWhitespaceOnly(String str); @Nullable static String concatenateWithAnd(@Nullable String s1, @Nullable String s2); static String toQuotedListString(Object[] values); }
StringUtils { public static String showControlCharacters(String str) { int len = str.length(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i += 1) { char c = str.charAt(i); switch (c) { case '\b': sb.append("\\b"); break; case '\t': sb.append("\\t"); break; case '\n': sb.append("\\n"); break; case '\f': sb.append("\\f"); break; case '\r': sb.append("\\r"); break; default: sb.append(c); } } return sb.toString(); } private  StringUtils(); static String byteToHexString(final byte[] bytes, final int start, final int end); static String byteToHexString(final byte[] bytes); static byte[] hexStringToByte(final String hex); static String arrayAwareToString(Object o); static String arrayToString(Object array); static String showControlCharacters(String str); static String getRandomString(Random rnd, int minLength, int maxLength); static String getRandomString(Random rnd, int minLength, int maxLength, char minValue, char maxValue); static String generateRandomAlphanumericString(Random rnd, int length); static void writeString(@Nonnull String str, DataOutputView out); static String readString(DataInputView in); static void writeNullableString(@Nullable String str, DataOutputView out); static @Nullable String readNullableString(DataInputView in); static boolean isNullOrWhitespaceOnly(String str); @Nullable static String concatenateWithAnd(@Nullable String s1, @Nullable String s2); static String toQuotedListString(Object[] values);  }