Pages

Monday, December 28, 2009

Create String Array from Vector

/**
* Method to assimilate the contents of a string vector (Vector) into a string array
* @param : stringVector - a Vector with String Objects
* @return String[]
*/

public String[] CreateStringArrayFromVector(Vector stringVector) {
//if the input parameter is a null value then return null
if (stringVector== null) return null;
//initialize the return value
String returnValue[]=new String[stringVector.size()];
Enumeration e=stringVector.elements();
int count=0;
//push the contents of the vector into a string array
while (e.hasMoreElements()) {
returnValue[count]=(String)e.nextElement();
count++;
}
return returnValue;
} //end of function::CreateStringArrayFromVector

No comments:

Post a Comment