public class RETokenizer
extends java.lang.Object
Pattern p=new Pattern("\\s+"); //any number of space characters String text="blah blah blah"; //by factory method RETokenizer tok1=p.tokenizer(text); //or by constructor RETokenizer tok2=new RETokenizer(p,text);Now the one way is to use the tokenizer as a token enumeration/iterator:
while(tok1.hasMore()) System.out.println(tok1.nextToken());and another way is to split it into a String array:
String[] arr=tok2.split(); for(int i=0;i
Pattern.tokenizer(java.lang.String)
Constructor and Description |
---|
RETokenizer(Matcher m,
boolean emptyEnabled) |
RETokenizer(Pattern pattern,
char[] chars,
int off,
int len) |
RETokenizer(Pattern pattern,
CharStream r,
int len) |
RETokenizer(Pattern pattern,
java.lang.String text) |
Modifier and Type | Method and Description |
---|---|
boolean |
hasMore() |
boolean |
hasMoreElements() |
boolean |
isEmptyEnabled() |
java.lang.Object |
nextElement() |
java.lang.String |
nextToken() |
void |
reset() |
void |
setEmptyEnabled(boolean b) |
java.lang.String[] |
split() |
public RETokenizer(Pattern pattern, java.lang.String text)
public RETokenizer(Pattern pattern, char[] chars, int off, int len)
public RETokenizer(Pattern pattern, CharStream r, int len) throws IOException
IOException
public RETokenizer(Matcher m, boolean emptyEnabled)
public void setEmptyEnabled(boolean b)
public boolean isEmptyEnabled()
public boolean hasMore()
public java.lang.String nextToken() throws ElementNotFoundException
ElementNotFoundException
public java.lang.String[] split() throws ElementNotFoundException
ElementNotFoundException
public void reset()
public boolean hasMoreElements()
public java.lang.Object nextElement() throws ElementNotFoundException
ElementNotFoundException