Here you can find the source of joinTokens(String tokens[], String pad)
Parameter | Description |
---|---|
tokens | a parameter |
pad | a parameter |
public static String joinTokens(String tokens[], String pad)
//package com.java2s; /*/* w w w.j a v a2s .c om*/ Jaivox version 0.7 March 2014 Copyright 2010-2014 by Bits and Pixels, Inc. 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 { /** * Join the words in the array into a String. This could be done with some * assumptions using java.util.Arrays, but the procedure below is simple enough * @param tokens * @param pad * @return */ public static String joinTokens(String tokens[], String pad) { StringBuffer sb = new StringBuffer(); int n = tokens.length; for (int i = 0; i < n - 1; i++) { sb.append(tokens[i]); sb.append(pad); } sb.append(tokens[n - 1]); String s = new String(sb); return s; } }