Java String Quote quote(String s)

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

Description

returns a quoted version of s with all internal quotes escaped

License

Open Source License

Declaration

static String quote(String s) 

Method Source Code

//package com.java2s;
/*//w  w  w.  j a  va 2s  .com
 * Utilities.java
 *
 * Created on February 13, 2007, 8:18 AM
 *
 * (c) 2009  The Echo Nest
 * See "license.txt" for terms
 *
 */

public class Main {
    /**
     * returns a quoted version of s with all internal quotes escaped
     */
    static String quote(String s) {
        String escaped = s.replaceAll("\\\"", "\\\\\"");
        return "\"" + escaped + "\"";
    }
}

Related

  1. quote(String s)
  2. quote(String s)
  3. quote(String s)
  4. quote(String s)
  5. quote(String s)
  6. quote(String s)
  7. quote(String s)
  8. quote(String s)
  9. quote(String s)