Java String Array Combine combine(String[] values, String regex)

Here you can find the source of combine(String[] values, String regex)

Description

combine

License

Open Source License

Declaration

public static String combine(String[] values, String regex) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String combine(String[] values, String regex) {
        if (values == null) {
            return null;
        }/*ww w . ja v  a 2 s .  c  o m*/
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < values.length; i++) {
            if (values[i] == null) {
                continue;
            }
            sb.append(values[i]);
            if (i < values.length - 1) {
                sb.append(regex);
            }
        }
        return sb.toString();
    }
}

Related

  1. combine(String... vals)
  2. combine(String[] a, String[] b, String glue)
  3. combine(String[] array1, String[] array2)
  4. combine(String[] strs, String delimeter)
  5. combine(String[] values, String delimiter)
  6. combine(String[] values, String separator)
  7. combine(String[] words)
  8. combineArray(String separator, String... stringArray)
  9. combineArray(String[] a, String[] b)