Android String Append append(final String string, final String append, final String delimiter)

Here you can find the source of append(final String string, final String append, final String delimiter)

Description

Appends the string `append` to `string` separated by the `delimiter` string.

License

Open Source License

Parameter

Parameter Description
string the string in front
append the string to append
delimiter the string that separates `string` and `append`

Return

appended string of `string` + `delimiter` + `append`, or `null` if `string` if `string` is `null`.

Declaration

public static String append(final String string, final String append,
        final String delimiter) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w w . j  av a  2  s .  co  m*/
     * Appends the string `append` to `string` separated by the `delimiter` string.
     * 
     * @param string
     *            the string in front
     * @param append
     *            the string to append
     * @param delimiter
     *            the string that separates `string` and `append`
     * @return appended string of `string` + `delimiter` + `append`, or `null` if `string` if `string` is `null`.
     */
    public static String append(final String string, final String append,
            final String delimiter) {
        if (string == null) {
            return append;
        } else {
            final StringBuilder builder = new StringBuilder(string);
            if (delimiter != null)
                builder.append(delimiter);
            if (append != null)
                builder.append(append);
            return builder.toString();
        }
    }
}

Related

  1. add(String str, int num)
  2. addSuffix(String src, String suffix)
  3. appendStr(Object... strs)
  4. concat(Object... chunks)