Skip to main content

BufferUnderflowException

java.nio.BufferUnderflowException

BufferUnderflowException is described in the javadoc comments as:

Unchecked exception thrown when a relative get operation reaches the source buffer's limit.
version: 1.14, 01/05/02 since: 1.4

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.

java.nio.Buffer.nextGetIndex()

/**
     * Checks the current position against the limit, throwing a {@link
     * BufferUnderflowException} if it is not smaller than the limit, and then
     * increments the position. 
     * @return  The current position value, before it is incremented
     */
final int nextGetIndex() {
    if (position >= limit) throw new BufferUnderflowException();
    return position++;
}

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

java.nio.Buffer.nextGetIndex(int)

final int nextGetIndex(int nb) {
    if (limit - position < nb) throw new BufferUnderflowException();
    int p = position;
    position += nb;
    return p;
}

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

java.nio.ByteBuffer.get(byte[], int, int)

/**
     * Relative bulk <i>get</i> method.
     *  This method transfers bytes from this buffer into the given
     * destination array.  If there are fewer bytes remaining in the
     * buffer than are required to satisfy the request, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * bytes are transferred and a {@link BufferUnderflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> bytes from this
     * buffer into the given array, starting at the current position of this
     * buffer and at the given offset in the array.  The position of this
     * buffer is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst[i] = src.get(); 
     * except that it first checks that there are sufficient bytes in
     * this buffer and it is potentially much more efficient. 
     * @param  dst
     *         The array into which bytes are to be written
     * @param  offset
     *         The offset within the array of the first byte to be
     *         written; must be non-negative and no larger than
     *         <tt>dst.length</tt>
     * @param  length
     *         The maximum number of bytes to be written to the given
     *         array; must be non-negative and no larger than
     *         <tt>dst.length - offset</tt>
     * @return  This buffer
     * @throws  BufferUnderflowException
     *          If there are fewer than <tt>length</tt> bytes
     *          remaining in this buffer
     * @throws  IndexOutOfBoundsException
     *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>
     *          parameters do not hold
     */
public ByteBuffer get(byte[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) dst[i] = get();
    return this;
}

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

java.nio.CharBuffer.get(char[], int, int)

/**
     * Relative bulk <i>get</i> method.
     *  This method transfers characters from this buffer into the given
     * destination array.  If there are fewer characters remaining in the
     * buffer than are required to satisfy the request, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * characters are transferred and a {@link BufferUnderflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> characters from this
     * buffer into the given array, starting at the current position of this
     * buffer and at the given offset in the array.  The position of this
     * buffer is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst[i] = src.get(); 
     * except that it first checks that there are sufficient characters in
     * this buffer and it is potentially much more efficient. 
     * @param  dst
     *         The array into which characters are to be written
     * @param  offset
     *         The offset within the array of the first character to be
     *         written; must be non-negative and no larger than
     *         <tt>dst.length</tt>
     * @param  length
     *         The maximum number of characters to be written to the given
     *         array; must be non-negative and no larger than
     *         <tt>dst.length - offset</tt>
     * @return  This buffer
     * @throws  BufferUnderflowException
     *          If there are fewer than <tt>length</tt> characters
     *          remaining in this buffer
     * @throws  IndexOutOfBoundsException
     *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>
     *          parameters do not hold
     */
public CharBuffer get(char[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) dst[i] = get();
    return this;
}

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

java.nio.DirectByteBuffer.get(byte[], int, int)

public ByteBuffer get(byte[] dst, int offset, int length) {
    if ((length << 0) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToByteArray(ix(pos), dst, offset << 0, length << 0); else Bits.copyToByteArray(ix(pos), dst, offset << 0, length << 0);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectCharBufferS.get(char[], int, int)

public CharBuffer get(char[] dst, int offset, int length) {
    if ((length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToCharArray(ix(pos), dst, offset << 1, length << 1); else Bits.copyToByteArray(ix(pos), dst, offset << 1, length << 1);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectCharBufferU.get(char[], int, int)

public CharBuffer get(char[] dst, int offset, int length) {
    if ((length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToCharArray(ix(pos), dst, offset << 1, length << 1); else Bits.copyToByteArray(ix(pos), dst, offset << 1, length << 1);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectDoubleBufferS.get(double[], int, int)

public DoubleBuffer get(double[] dst, int offset, int length) {
    if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToLongArray(ix(pos), dst, offset << 3, length << 3); else Bits.copyToByteArray(ix(pos), dst, offset << 3, length << 3);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectDoubleBufferU.get(double[], int, int)

public DoubleBuffer get(double[] dst, int offset, int length) {
    if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToLongArray(ix(pos), dst, offset << 3, length << 3); else Bits.copyToByteArray(ix(pos), dst, offset << 3, length << 3);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectFloatBufferS.get(float[], int, int)

public FloatBuffer get(float[] dst, int offset, int length) {
    if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToIntArray(ix(pos), dst, offset << 2, length << 2); else Bits.copyToByteArray(ix(pos), dst, offset << 2, length << 2);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectFloatBufferU.get(float[], int, int)

public FloatBuffer get(float[] dst, int offset, int length) {
    if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToIntArray(ix(pos), dst, offset << 2, length << 2); else Bits.copyToByteArray(ix(pos), dst, offset << 2, length << 2);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectIntBufferS.get(int[], int, int)

public IntBuffer get(int[] dst, int offset, int length) {
    if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToIntArray(ix(pos), dst, offset << 2, length << 2); else Bits.copyToByteArray(ix(pos), dst, offset << 2, length << 2);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectIntBufferU.get(int[], int, int)

public IntBuffer get(int[] dst, int offset, int length) {
    if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToIntArray(ix(pos), dst, offset << 2, length << 2); else Bits.copyToByteArray(ix(pos), dst, offset << 2, length << 2);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectLongBufferS.get(long[], int, int)

public LongBuffer get(long[] dst, int offset, int length) {
    if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToLongArray(ix(pos), dst, offset << 3, length << 3); else Bits.copyToByteArray(ix(pos), dst, offset << 3, length << 3);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectLongBufferU.get(long[], int, int)

public LongBuffer get(long[] dst, int offset, int length) {
    if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToLongArray(ix(pos), dst, offset << 3, length << 3); else Bits.copyToByteArray(ix(pos), dst, offset << 3, length << 3);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectShortBufferS.get(short[], int, int)

public ShortBuffer get(short[] dst, int offset, int length) {
    if ((length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToShortArray(ix(pos), dst, offset << 1, length << 1); else Bits.copyToByteArray(ix(pos), dst, offset << 1, length << 1);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DirectShortBufferU.get(short[], int, int)

public ShortBuffer get(short[] dst, int offset, int length) {
    if ((length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
        checkBounds(offset, length, dst.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferUnderflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyToShortArray(ix(pos), dst, offset << 1, length << 1); else Bits.copyToByteArray(ix(pos), dst, offset << 1, length << 1);
        position(pos + length);
    } else {
        super.get(dst, offset, length);
    }
    return this;
}

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

java.nio.DoubleBuffer.get(double[], int, int)

/**
     * Relative bulk <i>get</i> method.
     *  This method transfers doubles from this buffer into the given
     * destination array.  If there are fewer doubles remaining in the
     * buffer than are required to satisfy the request, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * doubles are transferred and a {@link BufferUnderflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> doubles from this
     * buffer into the given array, starting at the current position of this
     * buffer and at the given offset in the array.  The position of this
     * buffer is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst[i] = src.get(); 
     * except that it first checks that there are sufficient doubles in
     * this buffer and it is potentially much more efficient. 
     * @param  dst
     *         The array into which doubles are to be written
     * @param  offset
     *         The offset within the array of the first double to be
     *         written; must be non-negative and no larger than
     *         <tt>dst.length</tt>
     * @param  length
     *         The maximum number of doubles to be written to the given
     *         array; must be non-negative and no larger than
     *         <tt>dst.length - offset</tt>
     * @return  This buffer
     * @throws  BufferUnderflowException
     *          If there are fewer than <tt>length</tt> doubles
     *          remaining in this buffer
     * @throws  IndexOutOfBoundsException
     *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>
     *          parameters do not hold
     */
public DoubleBuffer get(double[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) dst[i] = get();
    return this;
}

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

java.nio.FloatBuffer.get(float[], int, int)

/**
     * Relative bulk <i>get</i> method.
     *  This method transfers floats from this buffer into the given
     * destination array.  If there are fewer floats remaining in the
     * buffer than are required to satisfy the request, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * floats are transferred and a {@link BufferUnderflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> floats from this
     * buffer into the given array, starting at the current position of this
     * buffer and at the given offset in the array.  The position of this
     * buffer is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst[i] = src.get(); 
     * except that it first checks that there are sufficient floats in
     * this buffer and it is potentially much more efficient. 
     * @param  dst
     *         The array into which floats are to be written
     * @param  offset
     *         The offset within the array of the first float to be
     *         written; must be non-negative and no larger than
     *         <tt>dst.length</tt>
     * @param  length
     *         The maximum number of floats to be written to the given
     *         array; must be non-negative and no larger than
     *         <tt>dst.length - offset</tt>
     * @return  This buffer
     * @throws  BufferUnderflowException
     *          If there are fewer than <tt>length</tt> floats
     *          remaining in this buffer
     * @throws  IndexOutOfBoundsException
     *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>
     *          parameters do not hold
     */
public FloatBuffer get(float[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) dst[i] = get();
    return this;
}

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

java.nio.HeapByteBuffer.get(byte[], int, int)

public ByteBuffer get(byte[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    System.arraycopy(hb, ix(position()), dst, offset, length);
    position(position() + length);
    return this;
}

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

java.nio.HeapCharBuffer.get(char[], int, int)

public CharBuffer get(char[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    System.arraycopy(hb, ix(position()), dst, offset, length);
    position(position() + length);
    return this;
}

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

java.nio.HeapDoubleBuffer.get(double[], int, int)

public DoubleBuffer get(double[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    System.arraycopy(hb, ix(position()), dst, offset, length);
    position(position() + length);
    return this;
}

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

java.nio.HeapFloatBuffer.get(float[], int, int)

public FloatBuffer get(float[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    System.arraycopy(hb, ix(position()), dst, offset, length);
    position(position() + length);
    return this;
}

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

java.nio.HeapIntBuffer.get(int[], int, int)

public IntBuffer get(int[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    System.arraycopy(hb, ix(position()), dst, offset, length);
    position(position() + length);
    return this;
}

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

java.nio.HeapLongBuffer.get(long[], int, int)

public LongBuffer get(long[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    System.arraycopy(hb, ix(position()), dst, offset, length);
    position(position() + length);
    return this;
}

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

java.nio.HeapShortBuffer.get(short[], int, int)

public ShortBuffer get(short[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    System.arraycopy(hb, ix(position()), dst, offset, length);
    position(position() + length);
    return this;
}

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

java.nio.IntBuffer.get(int[], int, int)

/**
     * Relative bulk <i>get</i> method.
     *  This method transfers ints from this buffer into the given
     * destination array.  If there are fewer ints remaining in the
     * buffer than are required to satisfy the request, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * ints are transferred and a {@link BufferUnderflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> ints from this
     * buffer into the given array, starting at the current position of this
     * buffer and at the given offset in the array.  The position of this
     * buffer is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst[i] = src.get(); 
     * except that it first checks that there are sufficient ints in
     * this buffer and it is potentially much more efficient. 
     * @param  dst
     *         The array into which ints are to be written
     * @param  offset
     *         The offset within the array of the first int to be
     *         written; must be non-negative and no larger than
     *         <tt>dst.length</tt>
     * @param  length
     *         The maximum number of ints to be written to the given
     *         array; must be non-negative and no larger than
     *         <tt>dst.length - offset</tt>
     * @return  This buffer
     * @throws  BufferUnderflowException
     *          If there are fewer than <tt>length</tt> ints
     *          remaining in this buffer
     * @throws  IndexOutOfBoundsException
     *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>
     *          parameters do not hold
     */
public IntBuffer get(int[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) dst[i] = get();
    return this;
}

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

java.nio.LongBuffer.get(long[], int, int)

/**
     * Relative bulk <i>get</i> method.
     *  This method transfers longs from this buffer into the given
     * destination array.  If there are fewer longs remaining in the
     * buffer than are required to satisfy the request, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * longs are transferred and a {@link BufferUnderflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> longs from this
     * buffer into the given array, starting at the current position of this
     * buffer and at the given offset in the array.  The position of this
     * buffer is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst[i] = src.get(); 
     * except that it first checks that there are sufficient longs in
     * this buffer and it is potentially much more efficient. 
     * @param  dst
     *         The array into which longs are to be written
     * @param  offset
     *         The offset within the array of the first long to be
     *         written; must be non-negative and no larger than
     *         <tt>dst.length</tt>
     * @param  length
     *         The maximum number of longs to be written to the given
     *         array; must be non-negative and no larger than
     *         <tt>dst.length - offset</tt>
     * @return  This buffer
     * @throws  BufferUnderflowException
     *          If there are fewer than <tt>length</tt> longs
     *          remaining in this buffer
     * @throws  IndexOutOfBoundsException
     *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>
     *          parameters do not hold
     */
public LongBuffer get(long[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) dst[i] = get();
    return this;
}

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

java.nio.ShortBuffer.get(short[], int, int)

/**
     * Relative bulk <i>get</i> method.
     *  This method transfers shorts from this buffer into the given
     * destination array.  If there are fewer shorts remaining in the
     * buffer than are required to satisfy the request, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * shorts are transferred and a {@link BufferUnderflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> shorts from this
     * buffer into the given array, starting at the current position of this
     * buffer and at the given offset in the array.  The position of this
     * buffer is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst[i] = src.get(); 
     * except that it first checks that there are sufficient shorts in
     * this buffer and it is potentially much more efficient. 
     * @param  dst
     *         The array into which shorts are to be written
     * @param  offset
     *         The offset within the array of the first short to be
     *         written; must be non-negative and no larger than
     *         <tt>dst.length</tt>
     * @param  length
     *         The maximum number of shorts to be written to the given
     *         array; must be non-negative and no larger than
     *         <tt>dst.length - offset</tt>
     * @return  This buffer
     * @throws  BufferUnderflowException
     *          If there are fewer than <tt>length</tt> shorts
     *          remaining in this buffer
     * @throws  IndexOutOfBoundsException
     *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>
     *          parameters do not hold
     */
public ShortBuffer get(short[] dst, int offset, int length) {
    checkBounds(offset, length, dst.length);
    if (length > remaining()) throw new BufferUnderflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) dst[i] = get();
    return this;
}

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

java.nio.charset.CoderResult.throwException()

/**
     * Throws an exception appropriate to the result described by this object.
     *
     * @throws  BufferUnderflowException
     *          If this object is {@link #UNDERFLOW}
     * @throws  BufferOverflowException
     *          If this object is {@link #OVERFLOW}
     * @throws  MalformedInputException
     *          If this object represents a malformed-input error; the
     *          exception's length value will be that of this object
     * @throws  UnmappableCharacterException
     *          If this object represents an unmappable-character error; the
     *          exceptions length value will be that of this object
     */
public void throwException() throws CharacterCodingException {
    switch(type) {
        case CR_UNDERFLOW:
            throw new BufferUnderflowException();
        case CR_OVERFLOW:
            throw new BufferOverflowException();
        case CR_MALFORMED:
            throw new MalformedInputException(length);
        case CR_UNMAPPABLE:
            throw new UnmappableCharacterException(length);
        default:
            assert false;
    }
}

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