Java Stream Join joinStringsAsArguments(Stream arguments)

Here you can find the source of joinStringsAsArguments(Stream arguments)

Description

join Strings As Arguments

License

Open Source License

Declaration

static String joinStringsAsArguments(Stream<String> arguments) 

Method Source Code

//package com.java2s;
/*//ww  w  .j  av  a2s .  c o  m
 * Copyright (c) 2017, Jean-Baptiste Giraudeau <jb@giraudeau.info>
 *
 * This file is part of "Derive4J - Annotation Processor".
 *
 * "Derive4J - Annotation Processor" is free software: you can redistribute it
 * and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * "Derive4J - Annotation Processor" is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with "Derive4J - Annotation Processor".  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.stream.Stream;

public class Main {
    static String joinStringsAsArguments(Stream<String> arguments) {

        return joinStrings(arguments, ", ");
    }

    static String joinStrings(Stream<String> strings, String joiner) {

        return strings.reduce((s1, s2) -> s1 + joiner + s2).orElse("");
    }
}

Related

  1. join(final String delimiter, final Stream stream)
  2. join(Stream vals)
  3. join(Stream stream)