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.

[542 byte] By [p_spanidisa] at [2007-11-27 0:01:00]
# 1

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

ayusman_dikshita at 2007-7-11 15:51:44 > top of Java-index,Java Essentials,New To Java...
# 2

>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)

java_2006a at 2007-7-11 15:51:44 > top of Java-index,Java Essentials,New To Java...
# 3

> 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.

uncle_alicea at 2007-7-11 15:51:44 > top of Java-index,Java Essentials,New To Java...
# 4
yes.... use the split() method in String class.... construct ur regex to split ur string based on a word.. refer to the String JavaDoc for more info
khookha at 2007-7-11 15:51:45 > top of Java-index,Java Essentials,New To Java...