Skip to main content

EOFException

java.io.EOFException

EOFException is described in the javadoc comments as:

Signals that an end of file or end of stream has been reached unexpectedly during input.

This exception is mainly used by data input streams to signal end of stream. Note that many other input operations return a special value on end of stream rather than throwing an exception.


author: Frank Yellin version: 1.13, 12/19/03 see: java.io.DataInputStream see: java.io.IOException since: JDK1.0

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(int, boolean)

/**
     * Loads a chunk of text.
     * @param offset       The offset into the character buffer to
     *                     read the next batch of characters.
     * @param changeEntity True if the load should change entities
     *                     at the end of the entity, otherwise leave
     *                     the current entity in place and the entity
     *                     boundary will be signaled by the return
     *                     value.
     * @returns Returns true if the entity changed as a result of this
     *          load operation.
     */
final boolean load(int offset, boolean changeEntity) throws IOException {
    if (DEBUG_BUFFER) {
        System.out.print('(load, ' + offset + ': ');
        XMLEntityManager.print(fCurrentEntity);
        System.out.println();
    }
    int length = fCurrentEntity.mayReadChunks ? (fCurrentEntity.ch.length - offset) : (XMLEntityManager.DEFAULT_XMLDECL_BUFFER_SIZE);
    if (DEBUG_BUFFER) System.out.println('  length to try to read: ' + length);
    int count = fCurrentEntity.reader.read(fCurrentEntity.ch, offset, length);
    if (DEBUG_BUFFER) System.out.println('  length actually read:  ' + count);
    boolean entityChanged = false;
    if (count != -1) {
        if (count != 0) {
            fCurrentEntity.count = count + offset;
            fCurrentEntity.position = offset;
        }
    } else {
        fCurrentEntity.count = offset;
        fCurrentEntity.position = offset;
        entityChanged = true;
        if (changeEntity) {
            fEntityManager.endEntity();
            if (fCurrentEntity == null) {
                throw new EOFException();
            }
            if (fCurrentEntity.position == fCurrentEntity.count) {
                load(0, true);
            }
        }
    }
    if (DEBUG_BUFFER) {
        System.out.print(')load, ' + offset + ': ');
        XMLEntityManager.print(fCurrentEntity);
        System.out.println();
    }
    return entityChanged;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.DataInputStream.readBoolean()

/**
     * See the general contract of the <code>readBoolean</code>
     * method of <code>DataInput</code>.
     * Bytes
     * for this operation are read from the contained
     * input stream.
     * @return     the <code>boolean</code> value read.
     * @exception  EOFException  if this input stream has reached the end.
     * @exception  IOException   if an I/O error occurs.
     * @see        java.io.FilterInputStream#in
     */
public final boolean readBoolean() throws IOException {
    int ch = in.read();
    if (ch < 0) throw new EOFException();
    return (ch != 0);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.DataInputStream.readByte()

/**
     * See the general contract of the <code>readByte</code>
     * method of <code>DataInput</code>.
     * Bytes
     * for this operation are read from the contained
     * input stream.
     * @return     the next byte of this input stream as a signed 8-bit
     *             <code>byte</code>.
     * @exception  EOFException  if this input stream has reached the end.
     * @exception  IOException   if an I/O error occurs.
     * @see        java.io.FilterInputStream#in
     */
public final byte readByte() throws IOException {
    int ch = in.read();
    if (ch < 0) throw new EOFException();
    return (byte) (ch);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.DataInputStream.readChar()

/**
     * See the general contract of the <code>readChar</code>
     * method of <code>DataInput</code>.
     * Bytes
     * for this operation are read from the contained
     * input stream.
     * @return     the next two bytes of this input stream as a Unicode
     *             character.
     * @exception  EOFException  if this input stream reaches the end before
     *               reading two bytes.
     * @exception  IOException   if an I/O error occurs.
     * @see        java.io.FilterInputStream#in
     */
public final char readChar() throws IOException {
    int ch1 = in.read();
    int ch2 = in.read();
    if ((ch1 | ch2) < 0) throw new EOFException();
    return (char) ((ch1 << 8) + (ch2 << 0));
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.DataInputStream.readFully(byte, int, int)

/**
     * See the general contract of the <code>readFully</code>
     * method of <code>DataInput</code>.
     * Bytes
     * for this operation are read from the contained
     * input stream.
     * @param      b     the buffer into which the data is read.
     * @param      off   the start offset of the data.
     * @param      len   the number of bytes to read.
     * @exception  EOFException  if this input stream reaches the end before
     *               reading all the bytes.
     * @exception  IOException   if an I/O error occurs.
     * @see        java.io.FilterInputStream#in
     */
public final void readFully(byte b[], int off, int len) throws IOException {
    if (len < 0) throw new IndexOutOfBoundsException();
    int n = 0;
    while (n < len) {
        int count = in.read(b, off + n, len - n);
        if (count < 0) throw new EOFException();
        n += count;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.DataInputStream.readInt()

/**
     * See the general contract of the <code>readInt</code>
     * method of <code>DataInput</code>.
     * Bytes
     * for this operation are read from the contained
     * input stream.
     * @return     the next four bytes of this input stream, interpreted as an
     *             <code>int</code>.
     * @exception  EOFException  if this input stream reaches the end before
     *               reading four bytes.
     * @exception  IOException   if an I/O error occurs.
     * @see        java.io.FilterInputStream#in
     */
public final int readInt() throws IOException {
    int ch1 = in.read();
    int ch2 = in.read();
    int ch3 = in.read();
    int ch4 = in.read();
    if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException();
    return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.DataInputStream.readShort()

/**
     * See the general contract of the <code>readShort</code>
     * method of <code>DataInput</code>.
     * Bytes
     * for this operation are read from the contained
     * input stream.
     * @return     the next two bytes of this input stream, interpreted as a
     *             signed 16-bit number.
     * @exception  EOFException  if this input stream reaches the end before
     *               reading two bytes.
     * @exception  IOException   if an I/O error occurs.
     * @see        java.io.FilterInputStream#in
     */
public final short readShort() throws IOException {
    int ch1 = in.read();
    int ch2 = in.read();
    if ((ch1 | ch2) < 0) throw new EOFException();
    return (short) ((ch1 << 8) + (ch2 << 0));
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.DataInputStream.readUnsignedByte()

/**
     * See the general contract of the <code>readUnsignedByte</code>
     * method of <code>DataInput</code>.
     * Bytes
     * for this operation are read from the contained
     * input stream.
     * @return     the next byte of this input stream, interpreted as an
     *             unsigned 8-bit number.
     * @exception  EOFException  if this input stream has reached the end.
     * @exception  IOException   if an I/O error occurs.
     * @see         java.io.FilterInputStream#in
     */
public final int readUnsignedByte() throws IOException {
    int ch = in.read();
    if (ch < 0) throw new EOFException();
    return ch;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.DataInputStream.readUnsignedShort()

/**
     * See the general contract of the <code>readUnsignedShort</code>
     * method of <code>DataInput</code>.
     * Bytes
     * for this operation are read from the contained
     * input stream.
     * @return     the next two bytes of this input stream, interpreted as an
     *             unsigned 16-bit integer.
     * @exception  EOFException  if this input stream reaches the end before
     *               reading two bytes.
     * @exception  IOException   if an I/O error occurs.
     * @see        java.io.FilterInputStream#in
     */
public final int readUnsignedShort() throws IOException {
    int ch1 = in.read();
    int ch2 = in.read();
    if ((ch1 | ch2) < 0) throw new EOFException();
    return (ch1 << 8) + (ch2 << 0);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.RandomAccessFile.readBoolean()

/**
     * Reads a <code>boolean</code> from this file. This method reads a 
     * single byte from the file, starting at the current file pointer. 
     * A value of <code>0</code> represents 
     * <code>false</code>. Any other value represents <code>true</code>. 
     * This method blocks until the byte is read, the end of the stream 
     * is detected, or an exception is thrown. 
     * @return     the <code>boolean</code> value read.
     * @exception  EOFException  if this file has reached the end.
     * @exception  IOException   if an I/O error occurs.
     */
public final boolean readBoolean() throws IOException {
    int ch = this.read();
    if (ch < 0) throw new EOFException();
    return (ch != 0);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.RandomAccessFile.readByte()

/**
     * Reads a signed eight-bit value from this file. This method reads a 
     * byte from the file, starting from the current file pointer. 
     * If the byte read is <code>b</code>, where 
     * <code>0 <= b <= 255</code>, 
     * then the result is:
     * <blockquote>
     *     (byte)(b)
     * </blockquote>
     * This method blocks until the byte is read, the end of the stream 
     * is detected, or an exception is thrown. 
     * @return     the next byte of this file as a signed eight-bit
     *             <code>byte</code>.
     * @exception  EOFException  if this file has reached the end.
     * @exception  IOException   if an I/O error occurs.
     */
public final byte readByte() throws IOException {
    int ch = this.read();
    if (ch < 0) throw new EOFException();
    return (byte) (ch);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.RandomAccessFile.readChar()

/**
     * Reads a Unicode character from this file. This method reads two
     * bytes from the file, starting at the current file pointer. 
     * If the bytes read, in order, are 
     * <code>b1</code> and <code>b2</code>, where 
     * <code>0 <= b1, b2 <= 255</code>, 
     * then the result is equal to:
     * <blockquote>
     *     (char)((b1 << 8) | b2)
     * </blockquote>
     * This method blocks until the two bytes are read, the end of the 
     * stream is detected, or an exception is thrown. 
     * @return     the next two bytes of this file as a Unicode character.
     * @exception  EOFException  if this file reaches the end before reading
     *               two bytes.
     * @exception  IOException   if an I/O error occurs.
     */
public final char readChar() throws IOException {
    int ch1 = this.read();
    int ch2 = this.read();
    if ((ch1 | ch2) < 0) throw new EOFException();
    return (char) ((ch1 << 8) + (ch2 << 0));
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.RandomAccessFile.readFully(byte, int, int)

/**
     * Reads exactly <code>len</code> bytes from this file into the byte 
     * array, starting at the current file pointer. This method reads 
     * repeatedly from the file until the requested number of bytes are 
     * read. This method blocks until the requested number of bytes are 
     * read, the end of the stream is detected, or an exception is thrown. 
     * @param      b     the buffer into which the data is read.
     * @param      off   the start offset of the data.
     * @param      len   the number of bytes to read.
     * @exception  EOFException  if this file reaches the end before reading
     *               all the bytes.
     * @exception  IOException   if an I/O error occurs.
     */
public final void readFully(byte b[], int off, int len) throws IOException {
    int n = 0;
    do {
        int count = this.read(b, off + n, len - n);
        if (count < 0) throw new EOFException();
        n += count;
    } while (n < len);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.RandomAccessFile.readInt()

/**
     * Reads a signed 32-bit integer from this file. This method reads 4 
     * bytes from the file, starting at the current file pointer. 
     * If the bytes read, in order, are <code>b1</code>,
     * <code>b2</code>, <code>b3</code>, and <code>b4</code>, where 
     * <code>0 <= b1, b2, b3, b4 <= 255</code>, 
     * then the result is equal to:
     * <blockquote>
     *     (b1 << 24) | (b2 << 16) + (b3 << 8) + b4
     * </blockquote>
     * This method blocks until the four bytes are read, the end of the 
     * stream is detected, or an exception is thrown. 
     * @return     the next four bytes of this file, interpreted as an
     *             <code>int</code>.
     * @exception  EOFException  if this file reaches the end before reading
     *               four bytes.
     * @exception  IOException   if an I/O error occurs.
     */
public final int readInt() throws IOException {
    int ch1 = this.read();
    int ch2 = this.read();
    int ch3 = this.read();
    int ch4 = this.read();
    if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException();
    return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.RandomAccessFile.readShort()

/**
     * Reads a signed 16-bit number from this file. The method reads two 
     * bytes from this file, starting at the current file pointer. 
     * If the two bytes read, in order, are 
     * <code>b1</code> and <code>b2</code>, where each of the two values is 
     * between <code>0</code> and <code>255</code>, inclusive, then the 
     * result is equal to:
     * <blockquote>
     *     (short)((b1 << 8) | b2)
     * </blockquote>
     * This method blocks until the two bytes are read, the end of the 
     * stream is detected, or an exception is thrown. 
     * @return     the next two bytes of this file, interpreted as a signed
     *             16-bit number.
     * @exception  EOFException  if this file reaches the end before reading
     *               two bytes.
     * @exception  IOException   if an I/O error occurs.
     */
public final short readShort() throws IOException {
    int ch1 = this.read();
    int ch2 = this.read();
    if ((ch1 | ch2) < 0) throw new EOFException();
    return (short) ((ch1 << 8) + (ch2 << 0));
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.RandomAccessFile.readUnsignedByte()

/**
     * Reads an unsigned eight-bit number from this file. This method reads 
     * a byte from this file, starting at the current file pointer, 
     * and returns that byte. 
     * This method blocks until the byte is read, the end of the stream 
     * is detected, or an exception is thrown. 
     * @return     the next byte of this file, interpreted as an unsigned
     *             eight-bit number.
     * @exception  EOFException  if this file has reached the end.
     * @exception  IOException   if an I/O error occurs.
     */
public final int readUnsignedByte() throws IOException {
    int ch = this.read();
    if (ch < 0) throw new EOFException();
    return ch;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.io.RandomAccessFile.readUnsignedShort()

/**
     * Reads an unsigned 16-bit number from this file. This method reads 
     * two bytes from the file, starting at the current file pointer. 
     * If the bytes read, in order, are 
     * <code>b1</code> and <code>b2</code>, where 
     * <code>0 <= b1, b2 <= 255</code>, 
     * then the result is equal to:
     * <blockquote>
     *     (b1 << 8) | b2
     * </blockquote>
     * This method blocks until the two bytes are read, the end of the 
     * stream is detected, or an exception is thrown. 
     * @return     the next two bytes of this file, interpreted as an unsigned
     *             16-bit integer.
     * @exception  EOFException  if this file reaches the end before reading
     *               two bytes.
     * @exception  IOException   if an I/O error occurs.
     */
public final int readUnsignedShort() throws IOException {
    int ch1 = this.read();
    int ch2 = this.read();
    if ((ch1 | ch2) < 0) throw new EOFException();
    return (ch1 << 8) + (ch2 << 0);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.zip.GZIPInputStream.readUByte(InputStream)

private int readUByte(InputStream in) throws IOException {
    int b = in.read();
    if (b == -1) {
        throw new EOFException();
    }
    return b;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.zip.GZIPInputStream.skipBytes(InputStream, int)

private void skipBytes(InputStream in, int n) throws IOException {
    while (n > 0) {
        int len = in.read(tmpbuf, 0, n < tmpbuf.length ? n : tmpbuf.length);
        if (len == -1) {
            throw new EOFException();
        }
        n -= len;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.zip.ZipInputStream.readFully(byte[], int, int)

private void readFully(byte[] b, int off, int len) throws IOException {
    while (len > 0) {
        int n = in.read(b, off, len);
        if (n == -1) {
            throw new EOFException();
        }
        off += n;
        len -= n;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.imageio.stream.ImageInputStreamImpl.readBit()

public int readBit() throws IOException {
    checkClosed();
    int newBitOffset = (this.bitOffset + 1) & 0x7;
    int val = read();
    if (val == -1) {
        throw new EOFException();
    }
    if (newBitOffset != 0) {
        seek(getStreamPosition() - 1);
        val >>= 8 - newBitOffset;
    }
    this.bitOffset = newBitOffset;
    return val & 0x1;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.imageio.stream.ImageInputStreamImpl.readBits(int)

public long readBits(int numBits) throws IOException {
    checkClosed();
    if (numBits < 0 || numBits > 64) {
        throw new IllegalArgumentException();
    }
    if (numBits == 0) {
        return 0L;
    }
    int bitsToRead = numBits + bitOffset;
    int newBitOffset = (this.bitOffset + numBits) & 0x7;
    long accum = 0L;
    while (bitsToRead > 0) {
        int val = read();
        if (val == -1) {
            throw new EOFException();
        }
        accum <<= 8;
        accum |= val;
        bitsToRead -= 8;
    }
    if (newBitOffset != 0) {
        seek(getStreamPosition() - 1);
    }
    this.bitOffset = newBitOffset;
    accum >>>= (-bitsToRead);
    accum &= (-1L >>> (64 - numBits));
    return accum;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.imageio.stream.ImageInputStreamImpl.readBoolean()

public boolean readBoolean() throws IOException {
    int ch = this.read();
    if (ch < 0) {
        throw new EOFException();
    }
    return (ch != 0);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.imageio.stream.ImageInputStreamImpl.readByte()

public byte readByte() throws IOException {
    int ch = this.read();
    if (ch < 0) {
        throw new EOFException();
    }
    return (byte) ch;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.imageio.stream.ImageInputStreamImpl.readFully(byte[], int, int)

public void readFully(byte[] b, int off, int len) throws IOException {
    if (off < 0 || len < 0 || off + len > b.length || off + len < 0) {
        throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > b.length!');
    }
    while (len > 0) {
        int nbytes = read(b, off, len);
        if (nbytes == -1) {
            throw new EOFException();
        }
        off += nbytes;
        len -= nbytes;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.imageio.stream.ImageInputStreamImpl.readInt()

public int readInt() throws IOException {
    int ch1 = this.read();
    int ch2 = this.read();
    int ch3 = this.read();
    int ch4 = this.read();
    if ((ch1 | ch2 | ch3 | ch4) < 0) {
        throw new EOFException();
    }
    if (byteOrder == ByteOrder.BIG_ENDIAN) {
        return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
    } else {
        return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0));
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.imageio.stream.ImageInputStreamImpl.readShort()

public short readShort() throws IOException {
    int ch1 = this.read();
    int ch2 = this.read();
    if ((ch1 | ch2) < 0) {
        throw new EOFException();
    }
    if (byteOrder == ByteOrder.BIG_ENDIAN) {
        return (short) ((ch1 << 8) + (ch2 << 0));
    } else {
        return (short) ((ch2 << 8) + (ch1 << 0));
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.imageio.stream.ImageInputStreamImpl.readUnsignedByte()

public int readUnsignedByte() throws IOException {
    int ch = this.read();
    if (ch < 0) {
        throw new EOFException();
    }
    return ch;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.zip.InflaterInputStream.fill()

/**
     * Fills input buffer with more data to decompress.
     * @exception IOException if an I/O error has occurred
     */
protected void fill() throws IOException {
    ensureOpen();
    len = in.read(buf, 0, buf.length);
    if (len == -1) {
        throw new EOFException('Unexpected end of ZLIB input stream');
    }
    inf.setInput(buf, 0, len);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.util.zip.ZipFile.getInputStream(String)

/**
     * Returns an input stream for reading the contents of the specified
     * entry, or null if the entry was not found.
     */
private InputStream getInputStream(String name) throws IOException {
    if (name == null) {
        throw new NullPointerException('name');
    }
    long jzentry = 0;
    ZipFileInputStream in = null;
    synchronized (this) {
        ensureOpen();
        jzentry = getEntry(jzfile, name, false);
        if (jzentry == 0) {
            return null;
        }
        if (mappedBuffer != null) {
            in = new MappedZipFileInputStream(jzentry, name);
        } else {
            in = new ZipFileInputStream(jzentry);
        }
    }
    final ZipFileInputStream zfin = in;
    switch(getMethod(jzentry)) {
        case STORED:
            return zfin;
        case DEFLATED:
            long size = getSize(jzentry) + 2;
            if (size > 65536) size = 8192;
            if (size <= 0) size = 4096;
            return new InflaterInputStream(zfin, getInflater(), (int) size) {

                private boolean isClosed = false;

                public void close() throws IOException {
                    if (!isClosed) {
                        releaseInflater(inf);
                        this.in.close();
                        isClosed = true;
                    }
                }

                protected void fill() throws IOException {
                    if (eof) {
                        throw new EOFException('Unexpected end of ZLIB input stream');
                    }
                    len = this.in.read(buf, 0, buf.length);
                    if (len == -1) {
                        buf[0] = 0;
                        len = 1;
                        eof = true;
                    }
                    inf.setInput(buf, 0, len);
                }

                private boolean eof;

                public int available() throws IOException {
                    if (isClosed) return 0;
                    long avail = zfin.size() - inf.getBytesWritten();
                    return avail > (long) Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) avail;
                }
            };
        default:
            throw new ZipException('invalid compression method');
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Comments

Popular posts from this blog

NullPointerException

java.lang.NullPointerException NullPointerException is described in the javadoc comments as: Thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of a null object. Accessing or modifying the field of a null object. Taking the length of null as if it were an array. Accessing or modifying the slots of null as if it were an array. Throwing null as if it were a Throwable value. Applications should throw instances of this class to indicate other illegal uses of the null object. author: unascribed version: 1.19, 12/19/03 since: JDK1.0 Where is this exception thrown? Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown. The message ' java.lang.NullPointerException: ' is thrown within the method: com.sun.corba.se.impl.interceptors.ClientRequestInfoImpl.get_r

Connection refused: No available router to destination

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators. Symptom The following exception occurs in WebLogic server logs. Most likely to occur during WebLogic server start-up, but similar exceptions may occur at other times. java.net.ConnectException: t3://myserver:8000: Destination unreachable; nested exception is: java.net.ConnectException: Connection refused: connect; No available router to destination] at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:49) at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:773) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:363) at weblogic.jndi.Environment.getContext(Environment.java:307) at weblogic.jndi.Environment.getContext(Environment.java:277) Cause This message (Connection refused: connect; No available

SocketException

java.net.SocketException SocketException is described in the javadoc comments as: Thrown to indicate that there is an error in the underlying protocol, such as a TCP error. author: Jonathan Payne version: 1.17, 12/19/03 since: JDK1.0 Where is this exception thrown? Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown. The message ' java.net.SocketException: ... ' is thrown within the method: java.net.ServerSocket.createImpl() The message ' java.net.SocketException: ... ' is thrown within the method: java.net.Socket.createImpl(boolean) The message ' java.net.SocketException: ... ' is thrown within the method: java.net.SocksSocketImpl.connect(SocketAddress, int) The message ' java.net.SocketException: ... ' is thrown within the method: java.net.SocksSocketImpl.socksBind(InetSocketAddress) The message