The following is one example of the use of the tokenizer. The code: StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens()) {
println(st.nextToken());
}
prints the following output: this
is
a
test
Since:
JDK1.0
多看看javadoc
while (st.hasMoreTokens()) {
println(st.nextToken());
}
prints the following output: this
is
a
test
Since:
JDK1.0
多看看javadoc
解决方案 »
- eclipse 中 打开pom.xml文件后关闭报错
- 关于自定义标签 为什么如果在tld文件中不配置uri,只在web.xml中配置taglib-uri后在JSP中引用无效呢?
- 急:服务器怎么将解析后的jsp页面保存为HTML静态文件。
- 请问如何使用js给jsp传参?
- [高分请教]Jsp调用servlet后的返回问题!!!
- 请大虾们推荐几本学习jsp和ejb得好书!
- jspSmart的上传程序,怎样能将上传的文件改名后存放在目录下?
- 紧急!!!这个问题为什么出错,我想是不应该的啊两个“ON”应该是相同的才对啊结果。。。。。
- linux下 mysql出现Duplicate entry '200' for key 'PRIMARY'
- 求解:springmvc + mybatis-spring-1.2.2 启动报错
- win98下可以运行那些jsp server???thinks
- 烦死啦,哪位帮帮忙!
还有,要是我想把空格换成字符A,怎么办?谢谢!
import java.util.*;
class stk
{
public static void main(String[] args)
{
System.out.println("Hello World!");
StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens())
{
System.out.println(st.nextToken());
} }
}
我输出的结果是正确的:
Hello World!
this
is
a
test
import java.util.*;
class stk
{
public static void main(String[] args)
{
System.out.println("Hello World!");
StringTokenizer st = new StringTokenizer("this is a test","a");
while (st.hasMoreTokens())
{
System.out.println(st.nextToken());
} }
}
请看这段javadoc :
StringTokenizer
public StringTokenizer(String str,
String delim)
Constructs a string tokenizer for the specified string. The characters in the delim argument are the delimiters for separating tokens. Delimiter characters themselves will not be treated as tokens.
Parameters:
str - a string to be parsed.
delim - the delimiters.