Here you can find the source of getStringFromTokens(Vector vector, String delimiter)
Parameter | Description |
---|---|
vector | list of tokens |
delimiter | String who delimiters the Strings into <I>str</I> |
public static String getStringFromTokens(Vector vector, String delimiter)
//package com.java2s; /**// w ww .j av a 2s . com * Copyright (C) 2012 Red Hat, Inc. and/or its affiliates. * * 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. */ import java.util.*; public class Main { /** * Return a String who contains the strings in the Vector <I>vector</I> * separated by <I>delimiter</I>. * * @param vector list of tokens * @param delimiter String who delimiters the Strings into <I>str</I> * @return Composed string */ public static String getStringFromTokens(Vector vector, String delimiter) { int nelem = vector.size(); // Initial capacity, at least include the delimiters StringBuffer str_ret = new StringBuffer(nelem * delimiter.length()); for (int i = 0; i < nelem; i++) { str_ret.append(vector.elementAt(i)); // The last delimiter isn't added if (i < nelem - 1) { str_ret.append(delimiter); } } return str_ret.toString(); } }