Java String Array Combine combineSplit(int startIndex, String[] string, String separator)

Here you can find the source of combineSplit(int startIndex, String[] string, String separator)

Description

Function to combine a String[] into a String

License

Open Source License

Parameter

Parameter Description
startIndex The index of String[] to start with
string The String[] you wish to combine
separator The separator to fill in between each object in String[]

Declaration

public static String combineSplit(int startIndex, String[] string, String separator) 

Method Source Code

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

public class Main {
    /**/*w w  w.j a  v a 2s. c om*/
     * Function to combine a String[] into a String
     *
     * @param startIndex The index of String[] to start with
     * @param string     The String[] you wish to combine
     * @param separator  The separator to fill in between each object in String[]
     * @return
     */
    public static String combineSplit(int startIndex, String[] string, String separator) {
        final StringBuilder builder = new StringBuilder();
        for (int i = startIndex; i < string.length; i++) {
            builder.append(string[i]);
            builder.append(separator);
        }
        builder.setLength(builder.length() - separator.length());
        return builder.toString();
    }
}

Related

  1. combineArray(String[] array, int offset)
  2. combineArray(String[] str, int start, int end)
  3. combineArrays(String[] array1, String[] array2)
  4. combineSplit(final int startIndex, final String[] string, final String seperator)
  5. combineSplit(int startIndex, String[] string, String separator)
  6. combineSplit(int startIndex, String[] string, String separator)
  7. combineString(String[] strArr, String glue)
  8. combineStringArray(String[] array, String delim)
  9. combineStrings(Object... strings)