title: Escape space with backslash in java
body: <p>I want to replace spaces from path string. I tried below but doesn't seems to be working :</p>
  
  <pre><code>String path = "/Users/TD/San Diego";
  path=path.replaceAll(" ","\\ ");
  System.out.println(path);
  </code></pre>
  
  <p>Goal is to convert </p>
  
  <blockquote>
    <p>"/Users/TD/San Diego" to "/Users/TD/San\ Diego"</p>
  </blockquote>
  
  <p>Any further space from string also needs to be replaced with "\ "</p>