History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-2804
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Paul King
Reporter: J David Eisenberg
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

I/O example on documentation web site fails

Created: 03/May/08 10:35 AM   Updated: 03/May/08 06:06 PM
Component/s: None
Affects Version/s: 1.5.5
Fix Version/s: 1.5.7, 1.6-beta-2

Time Tracking:
Not Specified

Environment: JVM 1.6.0-b105; running on Ubuntu 7.04 (I think)


 Description  « Hide
Example on page http://groovy.codehaus.org/Input+Output does not work; goes into an infinite loop:

new File("foo.txt").withReader { reader ->
while (true) { def line = reader.readLine() }
}

Either the documentation is wrong or Groovy is; don't know which.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Guillaume Laforge - 03/May/08 10:49 AM
Could you try with either 1.5.6 or 1.6-beta-1, I think this should be working with these versions.

J David Eisenberg - 03/May/08 11:09 AM
Fails on both 1.5.6 and 1.6-beta-1 (I put a println into the while loop; the word "null" is what appears after it hits end of file.

Paul King - 03/May/08 06:06 PM
The readLine() call on the underlying BufferedReader (at least in recent JVMs) just returns null when EOF is reached rather than throwing an exception. So, the doco is wrong in this instance. Wiki updated. Thanks for raising this.