I've read in lines from a text file before without any difficulties. However the text file i'm reading now has alot of semicolons, periods etc.. So I use a delimiter with alot of parameters. The problem is that the following code doesn't read in the entire text file, it starts about 200 lines down and goes right to the end. Even if I get rid of the delimiter, it doesn't start at the beginning of the file...Can anyone help me out with my code?
ok, well i think it will be better if you use the "split method "of String class instead of using the String Tokenizer.Below shown is the link where you will find the description of split method and the way you can use it.
If I've understood your description correctly (at this late hour), I think your program does just what you were expecting it to do, provided a few additional pieces are included.
When posting the example code, I'm guessing you maybe left out the pieces where you print or otherwise use the tokens read in.
For the following code example, I copied and pasted your code, and then I added a couple of lines that print the input data (in "raw" and "tokenized" fashions). I think it does what you want it to do. (Below, I'll also paste the "input.txt" file I tested with.)
To otherwise guess at what ailment is plaguing you... Do you perhaps have a development environment problem, where maybe an old version of your program code is mistakenly being run, or where maybe an old version of the input data is mistakenly being used?
I think the code works too. I think the problem is, is that my text file being read contains ALOT of lines and words. After further testing of my program I see that it is indeed processing all the lines and words properly. However, I still don't understand why they don't print to screen properly when I try and print the tokens or lines. It always starts at line, let's say 300 and prints out the results. When indeed it is processing previous lines. Very strange! Thanks for the help though!
I don't see anywhere in the code you originally posted where you write anything out anywhere. However let's suppose you actually have some code like what Dirk posted, and you're just writing the tokens out to the console.
Then, if you can't see the beginning of your output, it probably just scrolled off the top of the console window.