<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.util.StringTokenizer
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.util.html">This Package</a>  <a href="java.util.Stack.html#_top_">Previous</a>  <a href="java.util.TimeZone.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.util.StringTokenizer
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.util.StringTokenizer
</pre>
<hr>
<dl>
  <dt> public class <b>StringTokenizer</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
  <dt> implements <a href="java.util.Enumeration.html#_top_">Enumeration</a>
</dl>
The string tokenizer class allows an application to break a 
 string into tokens. The tokenization method is much simpler than 
 the one used by the <code>StreamTokenizer</code> class. The 
 <code>StringTokenizer</code> methods do not distinguish among 
 identifiers, numbers, and quoted strings, nor do they recognize 
 and skip comments. 
 <p>
 The set of delimiters (the characters that separate tokens) may 
 be specified either at creation time or on a per-token basis. 
 <p>
 An instance of <code>StringTokenizer</code> behaves in one of two 
 ways, depending on whether it was created with the 
 <code>returnTokens</code> flag having the value <code>true</code> 
 or <code>false</code>: 
 <ul>
 <li>If the flag is <code>false</code>, delimiter characters serve to 
     separate tokens. A token is a maximal sequence of consecutive 
     characters that are not delimiters. 
 <li>If the flag is <code>true</code>, delimiter characters are considered to
     be tokens. A token is either one delimiter character, or a maximal
     sequence of consecutive characters that are not delimiters.
 </ul>
 <p>
 The following is one example of the use of the tokenizer. The code:
 <blockquote><pre>
     StringTokenizer st = new StringTokenizer("this is a test");
     while (st.hasMoreTokens()) {
         println(st.nextToken());
     }
 </pre></blockquote>
 <p>
 prints the following output:
 <blockquote><pre>
     this
     is
     a
     test
 </pre></blockquote>
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.StreamTokenizer.html#_top_">StreamTokenizer</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#StringTokenizer(java.lang.String)"><b>StringTokenizer</b></a>(String)
  <dd>  Constructs a string tokenizer for the specified string.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#StringTokenizer(java.lang.String, java.lang.String)"><b>StringTokenizer</b></a>(String, String)
  <dd>  Constructs a string tokenizer for the specified string.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#StringTokenizer(java.lang.String, java.lang.String, boolean)"><b>StringTokenizer</b></a>(String, String, boolean)
  <dd>  Constructs a string tokenizer for the specified string.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#countTokens()"><b>countTokens</b></a>()
  <dd>  Calculates the number of times that this tokenizer's 
 <code>nextToken</code> method can be called before it generates an 
 exception.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#hasMoreElements()"><b>hasMoreElements</b></a>()
  <dd>  Returns the same value as the <code>hasMoreTokens</code>
 method.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#hasMoreTokens()"><b>hasMoreTokens</b></a>()
  <dd>  Tests if there are more tokens available from this tokenizer's string.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#nextElement()"><b>nextElement</b></a>()
  <dd>  Returns the same value as the <code>nextToken</code> method,
 except that its declared return value is <code>Object</code> rather than
 <code>String</code>.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#nextToken()"><b>nextToken</b></a>()
  <dd>  Returns the next token from this string tokenizer.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#nextToken(java.lang.String)"><b>nextToken</b></a>(String)
  <dd>  Returns the next token in this string tokenizer's string.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="StringTokenizer"></a>
<a name="StringTokenizer(java.lang.String, java.lang.String, boolean)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>StringTokenizer</b>
<pre>
 public StringTokenizer(<a href="java.lang.String.html#_top_">String</a> str,
                        <a href="java.lang.String.html#_top_">String</a> delim,
                        boolean returnTokens)
</pre>
<dl>
  <dd> Constructs a string tokenizer for the specified string. The 
 characters in the <code>delim</code> argument are the delimiters 
 for separating tokens. 
 <p>
 If the <code>returnTokens</code> flag is <code>true</code>, then 
 the delimiter characters are also returned as tokens. Each 
 delimiter is returned as a string of length one. If the flag is 
 <code>false</code>, the delimiter characters are skipped and only 
 serve as separators between tokens.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> str - a string to be parsed.
    <dd> delim - the delimiters.
    <dd> returnTokens - flag indicating whether to return the delimiters
                         as tokens.
  </dl></dd>
</dl>
<a name="StringTokenizer(java.lang.String, java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>StringTokenizer</b>
<pre>
 public StringTokenizer(<a href="java.lang.String.html#_top_">String</a> str,
                        <a href="java.lang.String.html#_top_">String</a> delim)
</pre>
<dl>
  <dd> Constructs a string tokenizer for the specified string. The 
 characters in the <code>delim</code> argument are the delimiters 
 for separating tokens.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> str - a string to be parsed.
    <dd> delim - the delimiters.
  </dl></dd>
</dl>
<a name="StringTokenizer(java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>StringTokenizer</b>
<pre>
 public StringTokenizer(<a href="java.lang.String.html#_top_">String</a> str)
</pre>
<dl>
  <dd> Constructs a string tokenizer for the specified string. The 
 tokenizer uses the default delimiter set, which is 
 <code>"&#92;t&#92;n&#92;r"</code>: the space character, the tab
 character, the newline character, and the carriage-return character.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> str - a string to be parsed.
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="hasMoreTokens()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="hasMoreTokens"><b>hasMoreTokens</b></a>
<pre>
 public boolean hasMoreTokens()
</pre>
<dl>
  <dd> Tests if there are more tokens available from this tokenizer's string.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> <code>true</code> if there are more tokens available from this
          tokenizer's string; <code>false</code> otherwise.
  </dl></dd>
</dl>
<a name="nextToken()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="nextToken"><b>nextToken</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> nextToken()
</pre>
<dl>
  <dd> Returns the next token from this string tokenizer.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the next token from this string tokenizer.
    <dt> <b>Throws:</b> <a href="java.util.NoSuchElementException.html#_top_">NoSuchElementException</a>
    <dd> if there are no more tokens in this
               tokenizer's string.
  </dl></dd>
</dl>
<a name="nextToken(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="nextToken"><b>nextToken</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> nextToken(<a href="java.lang.String.html#_top_">String</a> delim)
</pre>
<dl>
  <dd> Returns the next token in this string tokenizer's string. The new 
 delimiter set remains the default after this call.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> delim - the new delimiters.
    <dt> <b>Returns:</b>
    <dd> the next token, after switching to the new delimiter set.
    <dt> <b>Throws:</b> <a href="java.util.NoSuchElementException.html#_top_">NoSuchElementException</a>
    <dd> if there are no more tokens in this
               tokenizer's string.
  </dl></dd>
</dl>
<a name="hasMoreElements()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="hasMoreElements"><b>hasMoreElements</b></a>
<pre>
 public boolean hasMoreElements()
</pre>
<dl>
  <dd> Returns the same value as the <code>hasMoreTokens</code>
 method. It exists so that this class can implement the
 <code>Enumeration</code> interface.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> <code>true</code> if there are more tokens;
          <code>false</code> otherwise.
    <dt> <b>See Also:</b>
    <dd> <a href="java.util.Enumeration.html#_top_">Enumeration</a>, <a href="#hasMoreTokens()">hasMoreTokens</a>
  </dl></dd>
</dl>
<a name="nextElement()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="nextElement"><b>nextElement</b></a>
<pre>
 public <a href="java.lang.Object.html#_top_">Object</a> nextElement()
</pre>
<dl>
  <dd> Returns the same value as the <code>nextToken</code> method,
 except that its declared return value is <code>Object</code> rather than
 <code>String</code>. It exists so that this class can implement the
 <code>Enumeration</code> interface.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the next token in the string.
    <dt> <b>Throws:</b> <a href="java.util.NoSuchElementException.html#_top_">NoSuchElementException</a>
    <dd> if there are no more tokens in this
               tokenizer's string.
    <dt> <b>See Also:</b>
    <dd> <a href="java.util.Enumeration.html#_top_">Enumeration</a>, <a href="#nextToken()">nextToken</a>
  </dl></dd>
</dl>
<a name="countTokens()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="countTokens"><b>countTokens</b></a>
<pre>
 public int countTokens()
</pre>
<dl>
  <dd> Calculates the number of times that this tokenizer's 
 <code>nextToken</code> method can be called before it generates an 
 exception.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the number of tokens remaining in the string using the current
          delimiter set.
    <dt> <b>See Also:</b>
    <dd> <a href="#nextToken()">nextToken</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.util.html">This Package</a>  <a href="java.util.Stack.html#_top_">Previous</a>  <a href="java.util.TimeZone.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
