Skip to main content

Splitter Method/Function

1 reply [Last post]
abuhmead1987
Offline
Joined: 2010-04-21
Points: 0

/**
* @auther: Mohammad Abu Hmead
* This method used to split text have delimiter as string in j2me
* @param stringToBeSplitted
* @param delimiter
* @param vector
* @return returns vector holds all strings as array
*/
public Vector split(String stringToBeSplitted,String delimiter,Vector vector)
{

int delimiterIndex=stringToBeSplitted.indexOf(delimiter);
String string=stringToBeSplitted.substring(0, delimiterIndex);
String string1=stringToBeSplitted.substring(string.length()+3,stringToBeSplitted.length());
vector.addElement(string);

if(string1.indexOf(delimiter)!=-1 && !string1.equals(string1+"null"))
split(string1, delimiter,vector);
else
vector.addElement(string1);

return vector;
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
21 Guest
Offline
Joined: 2010-11-06
Points: 0

/** * @auther: Mohammad Abu Hmead * This method used to split text have
delimiter as string in j2me * @param stringToBeSplitted * @param delimiter *
@param vector * @return returns vector holds all strings as array */ public
Vector split(String stringToBeSplitted,String delimiter,Vector vector) { int
delimiterIndex=stringToBeSplitted.indexOf(delimiter); String
string=stringToBeSplitted.substring(0, delimiterIndex); String
string1=stringToBeSplitted.substring(string.length()+3,stringToBeSplitted.length());
vector.addElement(string); if(string1.indexOf(delimiter)!=-1 &&
!string1.equals(string1+"null")) split(string1, delimiter,vector); else
vector.addElement(string1); return vector; }