Here you can find the source of quoteReplacement(String s)
private static String quoteReplacement(String s)
//package com.java2s; public class Main { private static String quoteReplacement(String s) { if ((s.indexOf('\\') == -1) && (s.indexOf('$') == -1)) return s; StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '\\') { sb.append('\\'); sb.append('\\'); } else if (c == '$') { sb.append('\\'); sb.append('$'); } else { sb.append(c);//from ww w. j a va 2 s . c o m } } return sb.toString(); } }