Java Vector from String string2Vector(String s, String delimiter)

Here you can find the source of string2Vector(String s, String delimiter)

Description

Deserializing a string into a vector using a given delimiter to find single tokens.

License

LGPL

Parameter

Parameter Description
s The string to deserialize
delimiter The delimiter to tell tokens apart

Return

A vector of String as taken from s

Declaration

@SuppressWarnings({ "unchecked", "rawtypes" })
public static Vector string2Vector(String s, String delimiter) 

Method Source Code

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

import java.util.*;

public class Main {
    /**//from www. ja  v a 2s  . c o  m
     * Deserializing a string into a vector using a given delimiter to
     * find single tokens.
     *
     * @param s The string to deserialize
     * @param delimiter The delimiter to tell tokens apart
     * @return A vector of String as taken from <code>s</code>
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static Vector string2Vector(String s, String delimiter) {
        if (s == null || delimiter == null) {
            return null;
        }

        Vector v = new Vector();

        StringTokenizer st = new StringTokenizer(s, delimiter);
        while (st.hasMoreTokens()) {
            v.add(st.nextToken());
        }

        return v;
    }
}

Related

  1. implode(Vector strings, char delim)
  2. orderedStringInsert(String key, Vector into)
  3. parseArgumentVector(String argStr)
  4. reverseVector(final Vector src)
  5. reverseVector(Vector rc)
  6. stringArrayToVector(String[] array)
  7. stringToVector(String[] arr)
  8. stringVector(String input, String sepChars)
  9. unique(Vector list)