My program is suppose to read in a file and use the StringTokenizer to turn the file into tokens. However, I get a compile error when I try to read the file in.
Also, I am having trouble with my StringTokenizer. I'm not exactly sure how it's suppose to turn things into tokens. I referred to Java Sun's site, but their tutorial left me with many questions. So far I've gotten:
I am unsure what the nextToken method should exactly do since it returns a string. Any help would be appreciated.
Your reader looks about like mine. I have a little utility file reader because I can never remember this syntax. Here are two constructors:
What kind of compiler error do you get?
Re the Tokenizer, the code you showed will break a line into space-delimited words. So put it to work on one line at a time.
I'm not sure what you're supposed to do with the tokens ... maybe put them all in a big Vector or List or something.
That went a little further than we usually prefer toward giving you a working answer, but the examples here are very common bits of syntax ... hard to give out in much smaller bits. Hope it helps without taking away the fun (and value) of exploring things yourself!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop