﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Hello World-文章分类-Java基本</title><link>http://www.blogjava.net/siliconchip/category/15140.html</link><description>Java技术学习</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 08:21:08 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 08:21:08 GMT</pubDate><ttl>60</ttl><item><title>split()方法使用</title><link>http://www.blogjava.net/siliconchip/articles/69309.html</link><dc:creator>Java初心</dc:creator><author>Java初心</author><pubDate>Wed, 13 Sep 2006 01:50:00 GMT</pubDate><guid>http://www.blogjava.net/siliconchip/articles/69309.html</guid><wfw:comment>http://www.blogjava.net/siliconchip/comments/69309.html</wfw:comment><comments>http://www.blogjava.net/siliconchip/articles/69309.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/siliconchip/comments/commentRss/69309.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/siliconchip/services/trackbacks/69309.html</trackback:ping><description><![CDATA[
		<p>
				<font face="Arial" size="1">    有字符串"aa|bb"，想用split("|")分隔成String[]，但总是失败。后来发现split(String regex)的参数只能是正则表达式。改为split("[|]")分隔成功。<br />   另外应该还可以使用StringTokenizer<br />  </font>
		</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">String tstr</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">aa|bb</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />StringTokenizer st</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> StringTokenizer(tstr,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /></span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;st.hasMoreTokens();i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">){<br />  System.out.println(st.nextToken());<br />}</span>
		</div>
<img src ="http://www.blogjava.net/siliconchip/aggbug/69309.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/siliconchip/" target="_blank">Java初心</a> 2006-09-13 09:50 <a href="http://www.blogjava.net/siliconchip/articles/69309.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>