AndroidStringDocumentWriter { static String escapeQuotes(String str) { return Strings.nullToEmpty(str) .replaceAll("\"", "\\\\\"") .replaceAll("\n", "\\\\n"); } AndroidStringDocumentWriter(final AndroidStringDocument source); void buildDomSource(); String toText(); void toFile(String path);  }
@Test public void testEscapeQuotes() { assertThat(escapeQuotes(null)).isEqualTo(""); assertThat(escapeQuotes("")).isEqualTo(""); assertThat(escapeQuotes("String")).isEqualTo("String"); assertThat(escapeQuotes("second\\\"String")).isEqualTo("second\\\\\"String"); assertThat(escapeQuotes("third\nString")).isEqualTo("third\\nString"); assertThat(escapeQuotes("fourth\ntest\\\"String\\\"")).isEqualTo("fourth\\ntest\\\\\"String\\\\\""); }