Here you can find the source of combineSplit(final int startIndex, final String[] string, final String seperator)
Parameter | Description |
---|---|
startIndex | The index to start combining from. |
string | The array to combine from. |
seperator | The String to append between each String in the string array. |
public static String combineSplit(final int startIndex, final String[] string, final String seperator)
//package com.java2s; /******************************************************************************* * Copyright 2017 jamietech// ww w .ja v a 2s . com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ public class Main { /** * Turns a String[] into a single String separated by the passed separator. * @param startIndex The index to start combining from. * @param string The array to combine from. * @param seperator The String to append between each String in the string array. * @return A {@link String} containing all items from a string array with the provided separator between them. */ public static String combineSplit(final int startIndex, final String[] string, final String seperator) { if (startIndex + 1 > string.length) { return ""; } final StringBuilder builder = new StringBuilder(); for (int i = startIndex; i < string.length; i++) { builder.append(string[i]); builder.append(seperator); } builder.deleteCharAt(builder.length() - seperator.length()); return builder.toString(); } }