Forums Register Login

Printing randomly chosen words from a file

+Pie Number of slices to send: Send
Hi, i've gotta problem with it. i tried to use BufferedReader and then StringTokenizer, and than use a loop that will run random times, but it didn't work how i expected. I want to read whole file and print out couple of randomly chosen words :\
i've just started programming in java, and feel a bit lost in all this, sorry if it's a silly question

Before that, i tried with streamtokenizer, it compiles and runs but the words chosen by programm are really strange, like: "In and honour you here here peace honour In " and so on, some words are chosen lots of times.

In and honour you here here peace honour In

so, code looks like that:


[ February 26, 2008: Message edited by: Karol Klonowski ]
+Pie Number of slices to send: Send
 

Originally posted by Karol Klonowski:

Before that, i tried with streamtokenizer, it compiles and runs but the words chosen by programm are really strange, like: "In and honour you here here peace honour In " and so on, some words are chosen lots of times.



Welcome to the JavaRanch.
What do you expect the program to do?
What does your input look like?
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1031 times.
Similar Threads
how can i count the blank lines in a text file using stream tokenizer?
writing unicode to a file
StreamTokenizer and hard returns
StreamTokeniser Trouble
how to write result in file.....
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:33:58.