Here you can find the source of quote(String str)
public static String quote(String str)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from www. j av a 2 s. co m*/ * Quote and escape a string for use in shell commands. */ public static String quote(String str) { return "\"" + str.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"") + "\""; } }