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

PushbackInputStream.available() returns incorrect value.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.5
    • core-libs
    • x86
    • windows_nt



      Name: paC48320 Date: 06/23/98


      The available() method returns pos+super.available().
      It should return (buf.length-pos)+super.available(), like e.g. BufferedInputStream.

      import java.io.*;

      public class PushbackInputStreamTest
      extends PushbackInputStream
      {
        public static final String nullFilename
          // SYSTEM DEPENDENCY. Choose one or the other
          = "nul" // Windows, W95, NT, OS/2
      // = "/dev/null" // Unix &c
          ;
        public static void main(String[] args)
        {
          try
          {
            InputStream is = new PushbackInputStream(new FileInputStream(nullFilename));
            int avail = is.available();
            if (avail > 0)
              System.out.println("FAIL: avail="+avail);
            else
              System.out.println("PASS: avail="+avail);
            is.close();
          }
          catch (IOException ioe)
          {
            ioe.printStackTrace(System.err);
          }
        }
      }
      (Review ID: 28112)
      ======================================================================

            bgomessunw Benedict Gomes (Inactive)
            pallenba Peter Allenbach (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: