Java Vector to String vector2String(Vector v, String delimiter)

Here you can find the source of vector2String(Vector v, String delimiter)

Description

Serializing a Vector containing strings to a string using a given delimiter.

License

LGPL

Parameter

Parameter Description
v The vector to serialize
delimiter The delimiter to tell tokens apart

Return

A string containing the serialized contents of the Vector

Declaration

@SuppressWarnings("rawtypes")
public static String vector2String(Vector v, String delimiter) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.*;

public class Main {
    /**/* w  w  w.  j av  a 2 s  .com*/
     * Serializing a Vector containing strings to a string using a given delimiter.
     *
     * @param v The vector to serialize
     * @param delimiter The delimiter to tell tokens apart
     * @return A string containing the serialized contents of the Vector
     */
    @SuppressWarnings("rawtypes")
    public static String vector2String(Vector v, String delimiter) {
        if (v == null || delimiter == null) {
            return null;
        }

        return enumeration2String(v.elements(), delimiter);
    }

    @SuppressWarnings("rawtypes")
    public static String enumeration2String(Enumeration enume, String delimiter) {
        if (enume == null || delimiter == null) {
            return null;
        }

        StringBuffer buf = new StringBuffer();

        while (enume.hasMoreElements()) {
            buf.append(enume.nextElement());
            buf.append(delimiter);
        }

        return buf.toString();
    }
}

Related

  1. convertVectorToString(Vector source, String separator)
  2. convertVectorToStringArray(Vector vector)
  3. toStringArray(Vector V)
  4. vector2string(AbstractList v, String sep)
  5. vector_to_strings(Vector v)
  6. vectorString(Vector vec)
  7. vectorToNickNameArray(Vector nicksAndPaths)
  8. vectorToString(double[] v)