Java String Quote quoted(String value)

Here you can find the source of quoted(String value)

Description

Returns the given value wrapped in double-quote characters (") if the value is not null, or the string "null" if it is null.

License

Open Source License

Parameter

Parameter Description
value the value

Return

the string quoted (if not null), or "null"

Declaration

public static String quoted(String value) 

Method Source Code

//package com.java2s;
/*//  ww  w . j  a  va  2  s  . c  o m
 * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    /** Returns the given value wrapped in double-quote characters (") if the
     * value is not null, or the string {@code "null"} if it is null.
     *
     * @param value the value
     * @return the string quoted (if not null), or "null"
     */
    public static String quoted(String value) {
        return value == null ? "null" : "\"" + value + "\"";
    }
}

Related

  1. quoteD(String s)
  2. quoted(String s)
  3. quoted(String str)
  4. quoted(String text)
  5. quoted(String val, boolean wrap)
  6. quoted(String value, boolean addQuotes)
  7. quotedEscape(final String string)
  8. quotedIndexOf(String text, int start, int limit, String setOfChars)
  9. quotedJavaChar(char c, StringBuilder b)