Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-716

Reader.readLine() consumes too many characters.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-9
    • 1.1-beta-3
    • groovy-jdk
    • None
    • Groovy B9
      J2SE 1.5.0_1
      WinXP-SP2

    Description

      Example:
      import java.io.FileReader

      f=new FileReader(inputFile)
      header=f.readLine()
      println "==${header}=="
      f.readLines().each {
      println "###"it"###"
      }

      only works if "f" is decorated with a BufferedReader
      f=new BufferedReader(new FileReader(inputFile))
      otherwise "f" misses some lines.

      Cause:
      DefaultGroovyMethods.readLine constructs BufferedReader of "self", if "self" is not an instance of BufferedReader.
      BufferedReader does some readahead which "destroys" the FileReader contents.

      Attachments

        Activity

          People

            jbaumann Joachim Baumann
            pillath Andreas Pillath
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: