Here you can find the source of quote(String input)
private static CharSequence quote(String input)
//package com.java2s; //License from project: LGPL public class Main { private static CharSequence quote(String input) { StringBuilder sb = new StringBuilder(""); sb.append('"'); for (char c : input.toCharArray()) { if (c == '\n') { sb.append("\\n"); continue; }/*from ww w .j a va 2 s . c o m*/ if (c == '"' || c == '\'' || c == '\\') { sb.append('\\'); } sb.append(c); } sb.append('"'); return sb; } }