ref_send API 2.17
defensive programming in Java

org.joe_e.array
Class ByteArray.BuilderOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.joe_e.array.ByteArray.BuilderOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Enclosing class:
ByteArray

public static final class ByteArray.BuilderOutputStream
extends java.io.OutputStream

A ByteArray factory that extends OutputStream. All methods are simple wrappers around those provided by ByteArray.Builder.


Constructor Summary
ByteArray.BuilderOutputStream()
          Create an output stream using a new underlying ByteArray.Builder with the default internal array length
ByteArray.BuilderOutputStream(ByteArray.Builder toWrap)
          Create an output stream that wraps the specified ByteArray.Builder
ByteArray.BuilderOutputStream(int estimate)
          Create an output stream using a new underlying ByteArray.Builder
 
Method Summary
 int length()
          Gets the number of bytes written to the underlying ByteArray.Builder
 ByteArray snapshot()
          Create a snapshot of the current content.
 void write(byte[] b)
          Append a byte array to the underlying ByteArray.Builder
 void write(byte[] b, int off, int len)
          Append part of a byte array to the underlying ByteArray.Builder
 void write(int b)
          Append a byte to the underlying ByteArray.Builder
 
Methods inherited from class java.io.OutputStream
close, flush
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArray.BuilderOutputStream

public ByteArray.BuilderOutputStream()
Create an output stream using a new underlying ByteArray.Builder with the default internal array length


ByteArray.BuilderOutputStream

public ByteArray.BuilderOutputStream(int estimate)
Create an output stream using a new underlying ByteArray.Builder

Parameters:
estimate - estimated array length

ByteArray.BuilderOutputStream

public ByteArray.BuilderOutputStream(ByteArray.Builder toWrap)
Create an output stream that wraps the specified ByteArray.Builder

Parameters:
toWrap - the Builder to wrap
Method Detail

write

public void write(int b)
Append a byte to the underlying ByteArray.Builder

Specified by:
write in class java.io.OutputStream
Parameters:
b - the element to add

write

public void write(byte[] b)
Append a byte array to the underlying ByteArray.Builder

Overrides:
write in class java.io.OutputStream
Parameters:
b - the elements to add

write

public void write(byte[] b,
                  int off,
                  int len)
Append part of a byte array to the underlying ByteArray.Builder

Overrides:
write in class java.io.OutputStream
Parameters:
b - the elements to add
off - the index of the first element to add
len - the number of elements to add

length

public int length()
Gets the number of bytes written to the underlying ByteArray.Builder

Returns:
the number of elements that have been appended

snapshot

public ByteArray snapshot()
Create a snapshot of the current content.

Returns:
a ByteArray containing the elements so far

ref_send API 2.17
defensive programming in Java

Submit a bug or feature, or get help

Copyright 1998-2009 Waterken Inc. under the terms of the MIT X license.