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

PushbackInputStream.available() returns incorrect value.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.1.5
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: