BufferedReader readLine() implementation does not match javadoc

XMLWordPrintable

    • x86
    • os_x

      ADDITIONAL SYSTEM INFORMATION :
      This also seems to be broken in version 11

      A DESCRIPTION OF THE PROBLEM :
      https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/io/BufferedReader.html#readLine()
      states:
      Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), a carriage return followed immediately by a line feed, or by reaching the end-of-file (EOF).

      However, a line terminated by EOF (without a line feed or carriage return) is not returned and the text is simply lost when readLine returns null.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Read the lines of a file with the BufferedReader readLines method (alternatively use the lines() stream)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All lines up until EOF as specified by javadoc should be returned
      ACTUAL -
      Only lines terminated by line feed or carriage return are returned (as per previous versions' javadoc)

        1. OutputFile.java
          0.3 kB
        2. demo.txt
          0.0 kB

            Assignee:
            Pallavi Sonal (Inactive)
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: