StringTokenizer
Hello everybody.
I am trying to develop a software that will be able to identify some characters in a row. I thought that theStringTokenizeris doing such thing but and I used the characters that I wanted as delimiter. But I have realized that the delimiter of the StringTokenizer gets each one by one the characters of the delimiter and not as a whole word.
Do anyone of you know how can I do the same thing that theStringTokenizer does but using a whole word as a delimiter?
Thanks for your help.
If I understand your problem correctly
in the java API the constructor
public StringTokenizer(String str,
String delim,
boolean returnDelims)
does exactly what you want .. your delimiter can also be an String..
Hope this helps
>I am trying to develop a software that will be able to identify some characters in a row.
use regexp instead :http://java.sun.com/docs/books/tutorial/essential/regex/
>But I have realized that the delimiter of the StringTokenizer gets each one by one the characters of the delimiter and not as a whole word.
I don't think so. http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html#StringTokenizer(java.lang.String)
> If I understand your problem correctly
> in the java API the constructor
>
public StringTokenizer(String str,
String delim,
boolean returnDelims)
> does exactly what you want .. your delimiter can also
> be an String..
No, that's even worse: it will return each delimiter character, separately, along with the tokens. @OP, What you want is String's split() method.