Example usage for java.util.stream Collectors joining

List of usage examples for java.util.stream Collectors joining

Introduction

In this page you can find the example usage for java.util.stream Collectors joining.

Prototype

public static Collector<CharSequence, ?, String> joining(CharSequence delimiter) 

Source Link

Document

Returns a Collector that concatenates the input elements, separated by the specified delimiter, in encounter order.

Usage

From source file:com.zestedesavoir.zestwriter.utils.Configuration.java

/**
 * Add new content config files/*from  w  ww  .jav a 2 s .c o m*/
 * @param projectFileName file path of content you want to add
 */
public void addActionProject(String projectFileName) {
    List<String> existing = getActions();
    List<String> recent = new ArrayList<>(existing);
    if (recent.contains(projectFileName)) {
        recent.remove(projectFileName);
    }
    recent.add(0, projectFileName);

    actions.put(ActionData.LAST_PROJECTS.getKey(),
            recent.stream().limit(5).map(Object::toString).collect(Collectors.joining(",")));
    saveActionFile();
}