Java String Quote quote(String val)

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

Description

Wrap the provided val String in double-quotes.

License

Open Source License

Parameter

Parameter Description
val String to wrap in double-quotes

Return

val wrapped in quotes or a double-quoted empty string if val was null.

Declaration

static public String quote(String val) 

Method Source Code

//package com.java2s;
/** Copyright (C) (SAS) All rights reserved.
 ** General Public License: http://www.opensource.org/licenses/gpl-license.php
 **//*  w w  w  .j  a va  2s. c  o  m*/

public class Main {
    /**
     * Wrap the provided val String in double-quotes.
     * @param val String to wrap in double-quotes
     * @return val wrapped in quotes or a double-quoted empty string if 
     * val was null.
     */
    static public String quote(String val) {
        if (val == null)
            return "\"\"";
        return "\"" + val + "\"";
    }
}

Related

  1. quote(String text)
  2. quote(String text)
  3. quote(String text, String quote)
  4. quote(String toQuote, String specials, char quoteChar)
  5. quote(String txt)
  6. quote(String val)
  7. quote(String val, char quote)
  8. quote(String value)
  9. quote(String value)