Here you can find the source of quote(String txt)
public static String quote(String txt)
//package com.java2s; //License from project: Open Source License public class Main { public static String quote(String txt) { StringBuffer sb = new StringBuffer(""); sb.append(replace(replace(txt, "'", "'"), "", "'")); return sb.toString(); }//www.j a v a2 s . co m public static String replace(String str, String pattern, String replace) { int s = 0; int e = 0; StringBuffer result = new StringBuffer(); if (str != null) { while ((e = str.indexOf(pattern, s)) >= 0) { result.append(str.substring(s, e)); if (replace != null) result.append(replace); s = e + pattern.length(); } result.append(str.substring(s)); } return result.toString(); } }