title: Escape quote function in java not working
body: <p>I need to escape quotes from a string before printing them out.</p>
  
  <p>I've written a function, using char arrays to be as explicit as possible. But all this function seems to do is print out its own input:</p>
  
  <pre><code>public static String escapeQuotes(String myString) {
   char[] quote=new char[]{'"'};
   char[] escapedQuote=new char[]{'\\' , '"'};
   return myString.replaceAll(new String(quote), new String(escapedQuote));
  }
  
  public static void main(String[] args) throws Exception {
   System.out.println("asd\"");
   System.out.println(escapeQuotes("asd\""));
  }
  </code></pre>
  
  <p>I would expect the output of this to be:
  asd"
  asd\"</p>
  
  <p>However what I get is:
  asd"
  asd"</p>
  
  <p>Any ideas how to do this properly?</p>
  
  <p>Thanks</p>