FileDocCategorySizeDatePackage
ByteBufferInputStream.javaAPI DocExample4061Tue May 29 16:57:08 BST 2007com.sun.xml.ws.transport.tcp.io

ByteBufferInputStream

public class ByteBufferInputStream extends InputStream
Stream wrapper around a ByteBuffer

Fields Summary
private ByteBuffer
byteBuffer
The wrapped ByteBuffer
Constructors Summary
public ByteBufferInputStream(ByteBuffer byteBuffer)

        this.byteBuffer = byteBuffer;
    
Methods Summary
public intavailable()
Return the available bytes

return
the wrapped byteBuffer.remaining()

        return byteBuffer.remaining();
    
public voidclose()
Close this stream.

    
public booleanmarkSupported()
Return true if mark is supported.

        return false;
    
public intread()
Read the first byte from the wrapped ByteBuffer.

        if (!byteBuffer.hasRemaining()){
            return -1;
        }
        
        return (byteBuffer.get() & 0xff);
    
public intread(byte[] b)
Read the bytes from the wrapped ByteBuffer.

        return (read(b, 0, b.length));
    
public intread(byte[] b, int offset, int length)
Read the first byte of the wrapped ByteBuffer.

        if (!byteBuffer.hasRemaining()) {
            return -1;
        }
        
        if (length > available()) {
            length = available();
        }
        
        byteBuffer.get(b, offset, length);
        
        return length;
    
public voidsetByteBuffer(java.nio.ByteBuffer byteBuffer)
Set the wrapped ByteBuffer

param
byteBuffer The wrapped byteBuffer

        this.byteBuffer = byteBuffer;