public Vector split(String stringToBeSplitted, String delimiter) {
Vector vector = new Vector();
StringBuffer sb = new StringBuffer();
int delimiterIndex = stringToBeSplitted.indexOf(delimiter), delemitterLength = delimiter
.length();
if (delimiterIndex != -1) {
while (delimiterIndex != -1) {
sb.append(stringToBeSplitted.substring(0, delimiterIndex));
stringToBeSplitted = stringToBeSplitted.substring(sb.length()
+ delemitterLength, stringToBeSplitted.length());
vector.addElement(sb.toString());
// System.out.println(sb.toString());
sb.delete(0, sb.length());
delimiterIndex = stringToBeSplitted.indexOf(delimiter);
}
vector.addElement(stringToBeSplitted);
// System.out.println((String)vector.elementAt((vector.size()-1)));
} else {
vector.addElement(stringToBeSplitted);
}
sb = null;
stringToBeSplitted = null;
delimiter = null;
delemitterLength = 0;
delimiterIndex = 0;
return vector;
}
Mohammad Abu Hmead
No comments:
Post a Comment