stringtoList issue
Posted
by alpdog14
on Stack Overflow
See other posts from Stack Overflow
or by alpdog14
Published on 2010-03-25T21:18:09Z
Indexed on
2010/03/25
21:23 UTC
Read the original article
Hit count: 431
stringtokenizer
|java
I have a stringtoList ArrayList that needs to return tokens from a StreamTokenizer but the s.sval is not compiling at run-time, can anyone help me with this problem:
private List<Token> stringToList(final String string) {
// TODO your job
// follow Main.main but put the tokens into a suitable list
ArrayList<Token> al = new ArrayList<Token>();
String word = "";
String in = string;
StreamTokenizer s = new StreamTokenizer(new StringReader(in));
int token;
while ((token = s.nextToken()) != StreamTokenizer.TT_EOF) {
if (token == StreamTokenizer.TT_WORD) {
DefaultToken t = (s.sval, s.lineno()); //problem here, not reading the sval from the StreamTokenizer!!!
al.add(t);
}
return al;
}
}
Any help would be most appreciated
© Stack Overflow or respective owner