fixed some formatting typos
[vimdoclet.git] / sample / java.util.StringTokenizer.txt
blob4e0c0284994fcfa5a880096a47a7bd1625cfc89e
1 *java.util.StringTokenizer* *StringTokenizer* The string tokenizer class allows 
3 public class StringTokenizer
4   extends    |java.lang.Object|
5   implements |java.util.Enumeration|
7 |java.util.StringTokenizer_Description|
8 |java.util.StringTokenizer_Fields|
9 |java.util.StringTokenizer_Constructors|
10 |java.util.StringTokenizer_Methods|
12 ================================================================================
14 *java.util.StringTokenizer_Constructors*
15 |java.util.StringTokenizer(String)|Constructs a string tokenizer for the specif
16 |java.util.StringTokenizer(String,String)|Constructs a string tokenizer for the
17 |java.util.StringTokenizer(String,String,boolean)|Constructs a string tokenizer
19 *java.util.StringTokenizer_Methods*
20 |java.util.StringTokenizer.countTokens()|Calculates the number of times that th
21 |java.util.StringTokenizer.hasMoreElements()|Returns the same value as the hasM
22 |java.util.StringTokenizer.hasMoreTokens()|Tests if there are more tokens avail
23 |java.util.StringTokenizer.nextElement()|Returns the same value as the nextToke
24 |java.util.StringTokenizer.nextToken()|Returns the next token from this string 
25 |java.util.StringTokenizer.nextToken(String)|Returns the next token in this str
27 *java.util.StringTokenizer_Description*
29 The string tokenizer class allows an application to break a string into tokens. 
30 The tokenization method is much simpler than the one used by the 
31 StreamTokenizer class. The StringTokenizer methods do not distinguish among 
32 identifiers, numbers, and quoted strings, nor do they recognize and skip 
33 comments. 
35 The set of delimiters (the characters that separate tokens) may be specified 
36 either at creation time or on a per-token basis. 
38 An instance of StringTokenizer behaves in one of two ways, depending on whether 
39 it was created with the returnDelims flag having the value true or false: 
41 If the flag is false, delimiter characters serve to separate tokens. A token is 
42 a maximal sequence of consecutive characters that are not delimiters. If the 
43 flag is true, delimiter characters are themselves considered to be tokens. A 
44 token is thus either one delimiter character, or a maximal sequence of 
45 consecutive characters that are not delimiters. 
47 A StringTokenizer object internally maintains a current position within the 
48 string to be tokenized. Some operations advance this current position past the 
49 characters processed. A token is returned by taking a substring of the string 
50 that was used to create the StringTokenizer object. 
52 The following is one example of the use of the tokenizer. The code: 
54 StringTokenizer st = new StringTokenizer("this is a test"); while 
55 (st.hasMoreTokens()) { System.out.println(st.nextToken()); } 
57 prints the following output: 
59 this is a test 
61 StringTokenizer is a legacy class that is retained for compatibility reasons 
62 although its use is discouraged in new code. It is recommended that anyone 
63 seeking this functionality use the split method of String or the 
64 java.util.regex package instead. 
66 The following example illustrates how the String.split method can be used to 
67 break up a string into its basic tokens: 
69 String[] result = "this is a test".split("\\s"); for (int x=0; x<result.length; 
70 x++) System.out.println(result[x]); 
72 prints the following output: 
74 this is a test 
78 *java.util.StringTokenizer(String)*
80 public StringTokenizer(java.lang.String str)
82 Constructs a string tokenizer for the specified string. The tokenizer uses the 
83 default delimiter set, which is "tnrf": the space character, the tab character, 
84 the newline character, the carriage-return character, and the form-feed 
85 character. Delimiter characters themselves will not be treated as tokens. 
87     str - a string to be parsed. 
89 *java.util.StringTokenizer(String,String)*
91 public StringTokenizer(
92   java.lang.String str,
93   java.lang.String delim)
95 Constructs a string tokenizer for the specified string. The characters in the 
96 delim argument are the delimiters for separating tokens. Delimiter characters 
97 themselves will not be treated as tokens. 
99 Note that if delim is null, this constructor does not throw an exception. 
100 However, trying to invoke other methods on the resulting StringTokenizer may 
101 result in a NullPointerException. 
103     str - a string to be parsed. 
104     delim - the delimiters. 
106 *java.util.StringTokenizer(String,String,boolean)*
108 public StringTokenizer(
109   java.lang.String str,
110   java.lang.String delim,
111   boolean returnDelims)
113 Constructs a string tokenizer for the specified string. All characters in the 
114 delim argument are the delimiters for separating tokens. 
116 If the returnDelims flag is true, then the delimiter characters are also 
117 returned as tokens. Each delimiter is returned as a string of length one. If 
118 the flag is false, the delimiter characters are skipped and only serve as 
119 separators between tokens. 
121 Note that if delim is null, this constructor does not throw an exception. 
122 However, trying to invoke other methods on the resulting StringTokenizer may 
123 result in a NullPointerException. 
125     str - a string to be parsed. 
126     delim - the delimiters. 
127     returnDelims - flag indicating whether to return the delimiters as tokens. 
129 *java.util.StringTokenizer.countTokens()*
131 public int countTokens()
133 Calculates the number of times that this tokenizer's nextToken method can be 
134 called before it generates an exception. The current position is not advanced. 
138     Returns: the number of tokens remaining in the string using the current delimiter set. 
140 *java.util.StringTokenizer.hasMoreElements()*
142 public boolean hasMoreElements()
144 Returns the same value as the hasMoreTokens method. It exists so that this 
145 class can implement the Enumeration interface. 
149     Returns: true if there are more tokens; false otherwise. 
151 *java.util.StringTokenizer.hasMoreTokens()*
153 public boolean hasMoreTokens()
155 Tests if there are more tokens available from this tokenizer's string. If this 
156 method returns true, then a subsequent call to nextToken with no argument will 
157 successfully return a token. 
161     Returns: true if and only if there is at least one token in the string after the current 
162              position; false otherwise. 
164 *java.util.StringTokenizer.nextElement()*
166 public |java.lang.Object| nextElement()
168 Returns the same value as the nextToken method, except that its declared return 
169 value is Object rather than String. It exists so that this class can implement 
170 the Enumeration interface. 
174     Returns: the next token in the string. 
176 *java.util.StringTokenizer.nextToken()*
178 public |java.lang.String| nextToken()
180 Returns the next token from this string tokenizer. 
184     Returns: the next token from this string tokenizer. 
186 *java.util.StringTokenizer.nextToken(String)*
188 public |java.lang.String| nextToken(java.lang.String delim)
190 Returns the next token in this string tokenizer's string. First, the set of 
191 characters considered to be delimiters by this StringTokenizer object is 
192 changed to be the characters in the string delim. Then the next token in the 
193 string after the current position is returned. The current position is advanced 
194 beyond the recognized token. The new delimiter set remains the default after 
195 this call. 
198     delim - the new delimiters. 
200     Returns: the next token, after switching to the new delimiter set.