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

java.io.InputStream.skip: Incorrect and inefficient

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1, 1.1.3
    • core-libs
    • None
    • x86
    • windows_95, windows_nt



      Name: sgC58550 Date: 03/20/97


      The following code is from the source file for java.io.InputStream:

          public long skip(long n) throws IOException {
      /* ensure that the number is a positive int */
      byte data[] = new byte[(int) (n & 0xEFFFFFFF)];
      return read(data);
          }

      First, shouldn't that be 0x7FFFFFFF (not that anyone is likely to need to skip that many bytes)?
      Second, it seems horribly inefficient to allocate a large array to hold the data I am discarding.
      Wouldn't it be better to read the data and discard the bytes in a loop?

      company - , email - ###@###.###
      ======================================================================

            mr Mark Reinhold
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: