StringUtil { public static String escapeDoubleQuotes(String s) { return s.replace("\"", "\\\""); } protected  StringUtil(); static String[] splitAtLastSlash(String uri); static String suffixAfterLastSlash(String uri); static String escapeDoubleQuotes(String s);  }
@Test public void escapeDoubleQuotes() { String s; do { s = RandomStringUtils.random(20); } while (!s.contains("\"")); String[] split = StringUtil.escapeDoubleQuotes(s).split("\""); for (int i = 0; i < split.length - 1; i++) { assertThat(split[i]).endsWith("\\"); } }