Java List Join joinTokens(final List tokens)

Here you can find the source of joinTokens(final List tokens)

Description

Crudely join tokens together.

License

Open Source License

Parameter

Parameter Description
tokens a parameter
sb a parameter

Declaration

public final static StringBuffer joinTokens(final List<String> tokens) 

Method Source Code

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

import java.util.List;

public class Main {
    /**//  ww w  .  j  av a 2  s .  com
     * Crudely join tokens together.
     * 
     * @param tokens
     * @param sb
     * @return
     */
    public final static StringBuffer joinTokens(final List<String> tokens) {
        final StringBuffer sb = new StringBuffer();
        for (final String token : tokens) {
            sb.append(token);
            sb.append(" ");
        }

        return sb;
    }

    /**
     * Crudely join tokens together.
     * 
     * @param tokens
     * @param sb
     * @return
     */
    public final static StringBuffer joinTokens(final List<String> tokens,
            final StringBuffer sb) {
        for (final String token : tokens) {
            sb.append(token);
            sb.append(" ");
        }

        return sb;
    }
}

Related

  1. joinStrings(List strings, String separator)
  2. joinStrings(String delim, List strings)
  3. joinStrings(String joiner, List objects)
  4. joinTextWithCommas(List list)
  5. joinThreads(List threads)
  6. joinToString(List list)
  7. JoinToString(List list, String delimiter)
  8. joinUnique(List list, T element)
  9. joinWordList(List wordList, String delimiter)