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

java.io.PushbackInputStream.skip(n) needs to be implemented

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta3
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: saC57035 Date: 12/02/96


      The java.io.PushbackInputStream.skip(n) method isn't implemented.
      The parent skip(n) method is called instead, which simply ignores
      pushback bytes.

      Here is the example demonstrating the bug:

      -----------------Test.java------------------------
      import java.io.*;

      public class Test {

      public static void main( String argv[] ) {
       byte[] data = {30,40,50};
       int b;
       PushbackInputStream in = new PushbackInputStream(new ByteArrayInputStream(data));
       try {
         in.unread(20);
         if(in.skip(1) != 1) {
           System.out.println("Error: Cannot skip 1 byte");
           System.exit(1);
         }
         // User may expect that 30,40,50 remained in stream but see stdout..
         while((b=in.read()) != -1) System.out.print(b+" ");
         System.out.println();
       } catch (Throwable e) {
         System.out.println("Unexpected "+e+" is thrown");
       }
      }

      }
      ---------Output from the test---------------------
      20 40 50
      --------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              dviswanasunw Deepa Viswanathan (Inactive)
              Reporter:
              savzan Stanislav Avzan (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: