Java String Quote quote(String str, char c)

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

Description

Inserts a given character at the beginning and at the end of the specified string.

License

Mozilla Public License

Declaration

public static String quote(String str, char c) 

Method Source Code

//package com.java2s;
/**//from ww  w.j a  v  a  2  s .  co  m
 SpagoBI, the Open Source Business Intelligence suite
    
 Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center
 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this file,
 You can obtain one at http://mozilla.org/MPL/2.0/.
     
**/

public class Main {
    /**
     * Inserts a given character at the beginning and at the end of the specified string.
     * For example if the string is <tt>extreme</tt> and the char is <tt>'</tt> then 
     * the returned string is <tt>'exterme'</tt>.
     */
    public static String quote(String str, char c) {

        assert (str != null);
        StringBuffer buffer = new StringBuffer(str.length() + 2);
        buffer.append(c);
        buffer.append(str);
        buffer.append(c);
        return buffer.toString();
    }
}

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, String quoteChar)
  7. quote(String str, StringBuffer out)
  8. quote(String string)
  9. quote(String string)