我有一个 stringtoList ArrayList 需要从 StreamTokenizer 返回令牌,但 s.sval 没有在运行时编译,谁能帮我解决这个问题:
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;
}
}
非常感激任何的帮助