Skip to content

Instantly share code, notes, and snippets.

@dulichan
Created January 31, 2012 14:02
Show Gist options
  • Save dulichan/1710636 to your computer and use it in GitHub Desktop.
Save dulichan/1710636 to your computer and use it in GitHub Desktop.
J2me Splitter class
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