当前位置: 技术问答>java相关
JAVA里有没有可以按指定分割符分割字符串的函数?具体怎么用?
来源: 互联网 发布时间:2015-04-20
本文导语: JAVA里有没有可以按指定分割符分割字符串的函数?具体怎么用? | String sa="a,b,c,d,e"; import java.util.StringTokenizer; StringTokenizer b = new StringTokenizer(sa,","); while(b.hasMoreTokens()) Syste...
JAVA里有没有可以按指定分割符分割字符串的函数?具体怎么用?
|
String sa="a,b,c,d,e";
import java.util.StringTokenizer;
StringTokenizer b = new StringTokenizer(sa,",");
while(b.hasMoreTokens())
System.out.print(b.nextToken());
就可以取出来了
import java.util.StringTokenizer;
StringTokenizer b = new StringTokenizer(sa,",");
while(b.hasMoreTokens())
System.out.print(b.nextToken());
就可以取出来了
|
不知道,自己写了一个。看看对你又用么
public static String[] split(String value, String spliter)
{
if (value == null || value.equals(""))
return null;
ArrayList temp = new ArrayList();
int left = 0;
int index = 0;
int len = value.length();
while (index
public static String[] split(String value, String spliter)
{
if (value == null || value.equals(""))
return null;
ArrayList temp = new ArrayList();
int left = 0;
int index = 0;
int len = value.length();
while (index