Write code to escape Quotes
\ becomes \\.
You can use the replace method to escape string.
//package com.book2s; public class Main { public static void main(String[] argv) { String s = "book2s.com\""; System.out.println(escapeQuotes(s)); }//from w ww . j av a 2 s. c om public static String escapeQuotes(String s) { s = s.replace("\\", "\\\\"); s = s.replace("\"", "\\\""); return s; } }