Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6197654

(spec) LineNumberReader API docs incorrectly states that numbers start at 0

XMLWordPrintable

    • b57
    • sparc
    • solaris_9

      A DESCRIPTION OF THE PROBLEM :
      The documentation says: "By default, line numbering begins at 0." However it starts at 1.

      I wrote a little test routine to prove it to myself:

      import java.io.*;

      public class test {

          public static void main(String [] args) {
              try {
                  LineNumberReader lr = new LineNumberReader(new FileReader("/some/file/here.txt"));
                  String currentLine = null;
                  int currLine = -1;
                  
                  while ((currentLine = lr.readLine()) != null) {
                      currLine = lr.getLineNumber();
                      System.out.println("line nber " + currLine + " : " + currentLine);
                  }
                  lr.close();
              } catch (IOException e) {
                  System.err.println("Error: " + e);
              }
              
          }

      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      By default, line numbering begins at 1.
      ACTUAL -
      By default, line numbering begins at 0.

      URL OF FAULTY DOCUMENTATION :
      http://java.sun.com/j2se/1.4.2/docs/api/java/io/LineNumberReader.html

            iris Iris Clark
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: