Java Array Merge mergerBy(String[] target, String seperator)

Here you can find the source of mergerBy(String[] target, String seperator)

Description

merger By

License

Apache License

Declaration

public static String mergerBy(String[] target, String seperator) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {

    public static String mergerBy(List<String> target, String seperator) {
        return mergerBy(convertListToArray(target), seperator);
    }/*from  w  w w .  ja v  a  2 s .c o  m*/

    public static String mergerBy(String[] target, String seperator) {
        if (null == target) {
            return null;
        }

        StringBuilder sb = new StringBuilder(256);

        for (String str : target) {
            sb.append(str);
            sb.append(seperator);
        }

        return sb.substring(0, sb.lastIndexOf(seperator));
    }

    public static String[] convertListToArray(List<String> list) {
        return list.toArray(new String[0]);
    }
}

Related

  1. mergeBytearrays(byte[] ret, byte[] header, byte[] body)
  2. mergeCharArrays(char[] array1, char[] array2)
  3. mergeColumnsSafely(int[] arrOriginalColumns, int[] arrExtraColumns)
  4. mergeNoDuplicates(String[] in1, String[] in2)
  5. mergeParameterVariableNameDescription(String[] parameterType, String[] variableName)
  6. mergeSort(Object[] src, Object[] dest, int low, int high, int off)
  7. mergeSort(Object[] src, Object[] dest, int low, int high, int off, Comparator c)
  8. mergeSortArrays(String[][] arrayArray)
  9. mergeSortedInc(long[] a, long[] b)