Java List Concatenate concatValues(List stringValues, boolean spaceSeparated)

Here you can find the source of concatValues(List stringValues, boolean spaceSeparated)

Description

concat Values

License

Open Source License

Declaration

public static String concatValues(List<String> stringValues, boolean spaceSeparated) 

Method Source Code

//package com.java2s;
/*//from  w  w w  .  j  a  v a  2  s . c  om
*  Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*  WSO2 Inc. licenses this file to you 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.
*/

import java.util.List;

public class Main {
    public static String concatValues(List<String> stringValues, boolean spaceSeparated) {
        StringBuilder builder = new StringBuilder();
        String separator = spaceSeparated ? " " : ", ";
        for (int x = 0; x < stringValues.size(); ++x) {
            builder.append(stringValues.get(x));
            if (x != stringValues.size() - 1) {
                builder.append(separator);
            }
        }
        return builder.toString();
    }
}

Related

  1. concatString(List args)
  2. concatStrings(List values, String separator)
  3. concatSuper(List collection1, List collection2)
  4. concatSynopsises( List prefixes, List ss)
  5. concatTwoList(List fromList, List toList)
  6. concatWithSeparator(List list, Object delimiter)
  7. concatWithSeparator(List missingParameters, String separator)
  8. getConcatenatedStringFromList(List input, String delimiter)
  9. getConcatenateString(List codes)