WriterUtil { public static void appendEscapingQuotes(StringBuilder b, String value) { for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '"') b.append('\\'); b.append(c); } }  static void appendQuotedIfNonToken(StringBuilder b, String value); static void appendQuotedIfWhitespace(StringBuilder b, String value); static void appendQuoted(StringBuilder b, String value); static void appendEscapingQuotes(StringBuilder b, String value);  }
@Test public void testAppendEscapingQuotes() { StringBuilder sb = new StringBuilder(); WriterUtil.appendEscapingQuotes(sb, "a\"b"); assertEquals("a\\\"b", sb.toString()); sb = new StringBuilder(); WriterUtil.appendEscapingQuotes(sb, "abc"); assertEquals("abc", sb.toString()); }