com.vladium.util
Class ByteArrayOStream
java.lang.Object
java.io.OutputStream
com.vladium.util.ByteArrayOStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
public final class ByteArrayOStream
- extends java.io.OutputStream
An unsynchronized version of java.io.ByteArrayOutputStream that can expose
the underlying byte array without a defensive clone and can also be converted
to a ByteArrayIStream
without intermediate array copies.
All argument validation is disabled in release mode.
NOTE: copy-on-write not supported
- Author:
- (C) 2001, Vlad Roubtsov
Constructor Summary |
ByteArrayOStream(int initialCapacity)
Callee takes ownership of 'buf'. |
Methods inherited from class java.io.OutputStream |
flush, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_buf
private byte[] m_buf
m_pos
private int m_pos
NATIVE_COPY_THRESHOLD
private static final int NATIVE_COPY_THRESHOLD
- See Also:
- Constant Field Values
ByteArrayOStream
public ByteArrayOStream(int initialCapacity)
- Callee takes ownership of 'buf'.
toByteIStream
public final ByteArrayIStream toByteIStream()
write2
public final void write2(int b1,
int b2)
write3
public final void write3(int b1,
int b2,
int b3)
write4
public final void write4(int b1,
int b2,
int b3,
int b4)
writeTo
public final void writeTo(java.io.OutputStream out)
throws java.io.IOException
- Throws:
java.io.IOException
getByteArray
public final byte[] getByteArray()
copyByteArray
public final byte[] copyByteArray()
- Returns:
- [result.length = size()]
size
public final int size()
capacity
public final int capacity()
reset
public final void reset()
- Does not reduce the current capacity.
write
public final void write(int b)
- Specified by:
write
in class java.io.OutputStream
write
public final void write(byte[] buf,
int offset,
int length)
- Overrides:
write
in class java.io.OutputStream
close
public final void close()
- Equivalent to
reset()
.
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class java.io.OutputStream