Java Vector from String convertStringToVector(String source, String separator)

Here you can find the source of convertStringToVector(String source, String separator)

Description

Convert the passed String into a vector

License

Open Source License

Parameter

Parameter Description
source The string to convert
separator The seprator used by the source

Return

Vector with strings or null if source or separator not specified

Declaration

public static Vector convertStringToVector(String source,
        String separator) 

Method Source Code

//package com.java2s;
/* IBS Copyright/Security Notice ***************************************
 *                                              
 *  BAP Property of IBS AB/*w  w  w. ja va2  s .com*/
 *  (C) Copyright IBS AB 2001-2003
 *  All rights reserved.                        
 *  Use, duplication, or disclosure restricted  
 *  by license agreement with IBS AB.           
 *                                              
 *  Licensed Materials - Property of IBS AB     
 *                                              
 * End IBS Copyright/Security Notice **********************************
 *
 *
 * User  Date          Comment     
 * ---------------------------------------------------------------------
 * DMA   01/01/2000    Class created
 *  
 ***********************************************************************/

import java.util.*;

public class Main {
    /**
     * Convert the passed String into a vector
     *
     * @param   source      The string to convert
     * @param   separator   The seprator used by the source 
     * @return   Vector with strings or null if source or separator not specified
     */
    public static Vector convertStringToVector(String source,
            String separator) {

        if (source == null || separator == null) {
            return null;
        }

        Vector v = new Vector();
        StringTokenizer st = new StringTokenizer(source, separator);
        while (st.hasMoreTokens()) {
            v.addElement(st.nextToken().trim());
        }
        return v;
    }
}

Related

  1. constructFilter(String hostname, Vector schedulertypes)
  2. containSource(Vector sources, String source)
  3. createNodeValueVector(final String val)
  4. getKeyStringAsVector(String keyString, String separator)
  5. getposString(Vector vect_valores, String valor)
  6. getStringFromTokens(Vector vector, String delimiter)