org.apache.hadoop.hbase.io
Class ByteBufferOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.hadoop.hbase.io.ByteBufferOutputStream
All Implemented Interfaces:
Closeable, Flushable

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class ByteBufferOutputStream
extends OutputStream

Not thread safe!


Field Summary
protected  ByteBuffer buf
           
 
Constructor Summary
ByteBufferOutputStream(int capacity)
           
ByteBufferOutputStream(int capacity, boolean useDirectByteBuffer)
           
 
Method Summary
 void close()
           
 void flush()
           
 ByteBuffer getByteBuffer()
          This flips the underlying BB so be sure to use it _last_!
 int size()
           
 byte[] toByteArray(int offset, int length)
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 void writeTo(OutputStream out)
          Writes the complete contents of this byte buffer output stream to the specified output stream argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buf

protected ByteBuffer buf
Constructor Detail

ByteBufferOutputStream

public ByteBufferOutputStream(int capacity)

ByteBufferOutputStream

public ByteBufferOutputStream(int capacity,
                              boolean useDirectByteBuffer)
Method Detail

size

public int size()

getByteBuffer

public ByteBuffer getByteBuffer()
This flips the underlying BB so be sure to use it _last_!

Returns:
ByteBuffer

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

writeTo

public void writeTo(OutputStream out)
             throws IOException
Writes the complete contents of this byte buffer output stream to the specified output stream argument.

Parameters:
out - the output stream to which to write the data.
Throws:
IOException - if an I/O error occurs.

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

toByteArray

public byte[] toByteArray(int offset,
                          int length)


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.