Java String Quote quoteString(String s)

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

Description

quoteString

License

Open Source License

Parameter

Parameter Description
s a parameter

Declaration

public static String quoteString(String s) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 CA.  All rights reserved.
 *
 * This source file is licensed under the terms of the Eclipse Public License 1.0
 * For the full text of the EPL please see https://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

public class Main {
    /**/*from  ww  w  .  ja  va 2 s  .  c  om*/
     * quoteString
     * @param s
     * @return
     */
    public static String quoteString(String s) {

        String quoteStr = s.trim();

        if (!quoteStr.startsWith("'") && !quoteStr.endsWith("'")) {
            quoteStr = "'" + quoteStr + "'";

            return quoteStr;
        }

        return s;
    }
}

Related

  1. quoteString(String quoted, String quoteFlag)
  2. quoteString(String s)
  3. quoteString(String s)
  4. quoteString(String s)
  5. quoteString(String s)
  6. quoteString(String s)
  7. QuoteString(String source)
  8. quoteString(String source, char quote)
  9. quoteString(String src)