title: Replacing single '\' with '\\' in Java
body: <p>How do I replace a single <code>'\'</code> with <code>'\\'</code>?  When I run <code>replaceAll()</code> then I get this error message.</p>
  
  <pre><code>Exception in thread "main" java.util.regex.PatternSyntaxException:
                             Unexpected internal error near index 1 \
                                                                    ^
      at java.util.regex.Pattern.error(Pattern.java:1713)
      at java.util.regex.Pattern.compile(Pattern.java:1466)
      at java.util.regex.Pattern.&lt;init&gt;(Pattern.java:1133)
      at java.util.regex.Pattern.compile(Pattern.java:823)
      at java.lang.String.replaceAll(String.java:2190)
      at NewClass.main(NewClass.java:13)
  Java Result: 1
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>public class NewClass {
      public static void main(String[] args) {
          String str = "C:\\Documents and Settings\\HUSAIN\\My Documents\\My Palettes";
          str = str.replaceAll("\\", "\\\\");
          System.out.println(str);
      }
  }
  </code></pre>