Code example for ShortBufferException

0
    protected int engineGenerateSecret(byte[] sharedSecret, int offset)
            throws ShortBufferException { 
        checkCompleted(); 
        int available = sharedSecret.length - offset;
        if (mResult.length > available) {
            throw new ShortBufferException(
                    "Needed: " + mResult.length + ", available: " + available);
        } 
 
        System.arraycopy(mResult, 0, sharedSecret, offset, mResult.length);
        return mResult.length;
    } 
 
    @Override 
    protected byte[] engineGenerateSecret() { 
        checkCompleted(); 
        return mResult;
    } 
 
    @Override 
    protected SecretKey engineGenerateSecret(String algorithm) {