split的另外一种用法StringTokenizer

String softName="asa|asdasd|cddd|q|qq";
StringTokenizer commaToker = new StringTokenizer(softName, "|");
String[] arr = new String[commaToker.countTokens()];
for(int i=0;commaToker.hasMoreTokens();i++)
{
arr[i]=commaToker.nextToken();
}
String version=arr.length==0?arr[0]:arr[1];

你可能感兴趣的:(qq)