Here you can find the source of quoted(final String str)
public static final String quoted(final String str)
//package com.java2s; /*/*w ww. j a v a 2 s.co m*/ Copyright (c) 2000-2013 "independIT Integrative Technologies GmbH", Authors: Ronald Jeninga, Dieter Stubler schedulix Enterprise Job Scheduling System independIT Integrative Technologies GmbH [http://www.independit.de] mailto:contact@independit.de This file is part of schedulix schedulix is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static final String quoted(final String str) { final StringBuffer buf = new StringBuffer(str); for (int i = buf.length() - 1; i >= 0; --i) switch (buf.charAt(i)) { case '\'': case '\\': buf.insert(i, '\\'); } return buf.toString(); } }