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

ByteArrayInputStream reset API documentation inconsistent with API behaviour

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.2.2
    • docs
    • beta
    • generic
    • generic



      Name: skT45625 Date: 02/14/2000


      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      The behavior of ByteArrayInputStream.reset () seems to be inconsistent with the
      documentation when the method is invoked on an instance initialized with the
      ByteArrayInputStream (byte[], int, int) constructor.

      Here's an example:

      import java.io.ByteArrayInputStream;

      public class TestByteArrayInputStreamReset {

           public static void main (String[] args) {
               String s = "abcdefgh";
               ByteArrayInputStream bis =
                           new ByteArrayInputStream (s.getBytes(), 1, 4);

               // Confirm that the stream supports mark/reset.
               System.out.println ("Supports mark/reset: " + bis.markSupported ());

               // Read the first byte.
               System.out.println ("First byte:" + (char) bis.read ());

               // Reset the stream.
               bis.reset ();

               // Read the first byte again.
               System.out.println ("First byte after reset:" + (char) bis.read ());
           }
      }

      The output of this program is:

      Supports mark/reset: true
      First byte:b
      First byte after reset:b

      According to the API documentation at the
      URL http://java.sun.com/products/jdk/1.2/docs/api/index.html, invoking reset ()
      on the above instance would set the instance variable pos to zero, and the next
      byte to be read from the stream would be the ASCII value for a. However, the
      output of the program indicates that the stream has been reset to the position
      represented by the "offset" argument of the constructor used to initialize the
      stream.
      -----------------------------------------------------------
      ###@###.### 2000-02-14
      ByteApparInputStream API documentation needs to be updated to include the
      fact that;
                "If no mark has been set, then the value of mark is the offset passed to the
                 constructor(or 0 if the offset was not supplied). And a reset would reset the
                 current read position to the marked position"

      I suspect the docs to be old(1.1.4 )

      Suresh
      ###@###.###

      (Review ID: 101229)
      ======================================================================

            jhosunw Jamie Ho (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: