Java - Splitta Una Stringa
Join the DZone community and get the full member experience.
Join For Free
// Splitta una stringa
private String[] splitString(String str, String delims)
{
if(str == null)
return null;
else if(str.equals("") || delims == null || delims.length() == 0)
return new String[]{ str };
String[] s;
Vector v = new Vector();
int pos = 0;
int newpos = str.indexOf(delims, pos);;
while(newpos != -1)
{
v.addElement(str.substring(pos, newpos));
pos = newpos + delims.length();
newpos = str.indexOf(delims, pos);
}
v.addElement(str.substring(pos));
s = new String[v.size()];
for(int i=0, cnt=s.length; i
Java (programming language)
Opinions expressed by DZone contributors are their own.
Comments