Originally posted by omar salem: ...i get only the first character in the file printed on my screen continuously. Is my loop wrong? ...
Yes. Your loop only contains a single println statement. So all it does is print the same char over and over, without ever getting another char from the reader. You need to add a read statement inside the loop.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Jan 29, 2003
There's a neat bit of Java syntax that is not real obvious. Any assignment statement is also an expression with the value of whatever got assigned. So the assignment statement i=fr.read() has the value of whatever i gets. And you can test it in the same line:
That's sure to cause some head scratching the first time you see it (sure did for me) but it's common enough in real code that it will pay to remember it and get used to it.
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