Here you can find the source of getKeyStringAsVector(String keyString, String separator)
Parameter | Description |
---|---|
keyString | String with each key value separated by the separator |
separator | The sparator used in the key string |
public static Vector getKeyStringAsVector(String keyString, String separator)
//package com.java2s; /* IBS Copyright/Security Notice *************************************** * * BAP Property of IBS AB//from w w w . jav a 2 s . c om * (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 { /** * Return a vector of strings with one element per key value * * NOTE: An empty string ("") will be regarded as a value, therefor is * StringTokenizer not used. * * Example: ",A,,B," will result in Vector with 5 elements[ A B ] * For tokenizer would the result have been a Vector of 2 elements [AB] * * @param keyString String with each key value separated by the separator * @param separator The sparator used in the key string * @return Vector with one element per key */ public static Vector getKeyStringAsVector(String keyString, String separator) { if (keyString == null) { return null; } Vector v = new Vector(); int xb = 0; int xe = 0; boolean loop = true; while (loop) { xe = keyString.indexOf(separator, xb); if (xe < 0) { xe = keyString.length(); loop = false; } v.add(keyString.substring(xb, xe)); xb = xe + separator.length(); } return v; } }