示例#1
0
        /*
         * Skips {@code amount} number of bytes in this stream. Subsequent
         * {@code read()}'s will not return these bytes unless {@code reset()} is
         * used.
         *
         * @param amount
         *            the number of bytes to skip. {@code skip} does nothing and
         *            returns 0 if {@code amount} is less than zero.
         * @return the number of bytes actually skipped.
         * @throws IOException
         *             if this stream is closed or another IOException occurs.
         */

        public override long skip(long amount) //throws IOException
        {
            // Use local refs since buf and in may be invalidated by an
            // unsynchronized close()
            byte[]      localBuf = buf;
            InputStream localIn  = inJ;

            if (localBuf == null)
            {
                // luni.24=Stream is closed
                throw new IOException("Stream is closed"); //$NON-NLS-1$
            }
            if (amount < 1)
            {
                return(0);
            }
            if (localIn == null)
            {
                // luni.24=Stream is closed
                throw new IOException("Stream is closed"); //$NON-NLS-1$
            }

            if (count - pos >= amount)
            {
                pos += (int)amount;
                return(amount);
            }
            long read = count - pos;

            pos = count;

            if (markpos != -1)
            {
                if (amount <= marklimit)
                {
                    if (fillbuf(localIn, localBuf) == -1)
                    {
                        return(read);
                    }
                    if (count - pos >= amount - read)
                    {
                        pos += (int)(amount - read);
                        return(amount);
                    }
                    // Couldn't get all the bytes, skip what we read
                    read += (count - pos);
                    pos   = count;
                    return(read);
                }
            }
            return(read + localIn.skip(amount - read));
        }
示例#2
0
 public override long skip(long n)
 {
     return(inJ.skip(n));
 }