Created
January 31, 2012 14:02
-
-
Save dulichan/1710636 to your computer and use it in GitHub Desktop.
J2me Splitter class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Splitter { | |
public String[] split(String original, String separator) { | |
Vector nodes = new Vector(); | |
// Parse nodes into vector | |
int index = original.indexOf(separator); | |
while (index >= 0) { | |
nodes.addElement(original.substring(0, index)); | |
original = original.substring(index + separator.length()); | |
index = original.indexOf(separator); | |
} | |
// Get the last node | |
nodes.addElement(original); | |
// Create splitted string array | |
String[] result = new String[nodes.size()]; | |
if (nodes.size() > 0) { | |
for (int loop = 0; loop < nodes.size(); loop++) { | |
result[loop] = (String) nodes.elementAt(loop); | |
} | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment