File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Question about BufferedReader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about BufferedReader" Watch "Question about BufferedReader" New topic
Author

Question about BufferedReader

Shen Lin
Greenhorn

Joined: Mar 10, 2003
Posts: 10
The task is typing in some people's names and the output should be random pairs of these people. e.g.
[awana]abc: java Pairs
james
alex
jane
james and jane
alex
My program is shown below:
When running this program, the method randomPairs(nameSet) cannot be reached since the program cannot break out from the while-loop. I wonder how the method randomPairs(nameSet) can be executed after the while-loop.
Thanks,
Shen
Richard Jensen
Ranch Hand

Joined: May 14, 2003
Posts: 67
Originally posted by Shen Lin:
When running this program, the method randomPairs(nameSet) cannot be reached since the program cannot break out from the while-loop. I wonder how the method randomPairs(nameSet) can be executed after the while-loop.
Thanks,
Shen

When the input stream closes then the buffered reader will return null for the readLine.
So, if you run from the command line you need to enter your names (one per line) and then enter the appropriate end of stream character for your OS (on Windows it is Ctrl-Z).
It would also work by redirecting the contents of a file containing one name per line.


Richard
N 37 33 W 122 18
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about BufferedReader