Here you can find the source of addSlashes(String text)
protected static String addSlashes(String text)
//package com.java2s; //License from project: Creative Commons License import java.text.StringCharacterIterator; public class Main { protected static String addSlashes(String text) { final StringBuffer sb = new StringBuffer(text.length() * 2); final StringCharacterIterator iterator = new StringCharacterIterator(text); char character = iterator.current(); while (character != StringCharacterIterator.DONE) { if (character == '"') sb.append("\\\""); else if (character == '\'') sb.append("\\\'"); else if (character == '\\') sb.append("\\\\"); else if (character == '\n') sb.append("\\n"); else if (character == '{') sb.append("\\{"); else if (character == '}') sb.append("\\}"); else/*from www . ja v a2 s. c o m*/ sb.append(character); character = iterator.next(); } return sb.toString(); } }