org.apache.hadoop.hbase.io
Class ByteBufferInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.hadoop.hbase.io.ByteBufferInputStream
All Implemented Interfaces:
Closeable

@InterfaceAudience.Private
public class ByteBufferInputStream
extends InputStream

Not thread safe!

Please note that the reads will cause position movement on wrapped ByteBuffer.


Constructor Summary
ByteBufferInputStream(ByteBuffer buf)
           
 
Method Summary
 int available()
           
 int read()
          Reads the next byte of data from this input stream.
 int read(byte[] b, int off, int len)
          Reads up to next len bytes of data from buffer into passed array(starting from given offset).
 long skip(long n)
          Skips n bytes of input from this input stream.
 
Methods inherited from class java.io.InputStream
close, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferInputStream

public ByteBufferInputStream(ByteBuffer buf)
Method Detail

read

public int read()
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

Specified by:
read in class InputStream
Returns:
the next byte of data, or -1 if the end of the stream has been reached.

read

public int read(byte[] b,
                int off,
                int len)
Reads up to next len bytes of data from buffer into passed array(starting from given offset).

Overrides:
read in class InputStream
Parameters:
b - the array into which the data is read.
off - the start offset in the destination array b
len - the maximum number of bytes to read.
Returns:
the total number of bytes actually read into the buffer, or -1 if not even 1 byte can be read because the end of the stream has been reached.

skip

public long skip(long n)
Skips n bytes of input from this input stream. Fewer bytes might be skipped if the end of the input stream is reached. The actual number k of bytes to be skipped is equal to the smaller of n and remaining bytes in the stream.

Overrides:
skip in class InputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.

available

public int available()
Overrides:
available in class InputStream
Returns:
the number of remaining bytes that can be read (or skipped over) from this input stream.


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.