Java String Quote quote(String str)

Here you can find the source of quote(String str)

Description

Quote and escape a string for use in shell commands.

License

Open Source License

Declaration

public static String quote(String str) 

Method Source Code

//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("\"", "\\\\\"") + "\"";
    }
}

Related

  1. quote(String str)
  2. quote(String str)
  3. quote(String str)
  4. quote(String str)
  5. quote(String str)
  6. quote(String str, char c)
  7. quote(String str, String quoteChar)
  8. quote(String str, StringBuffer out)
  9. quote(String string)