Package com.yubico.yubikit.core.util
Class ZeroingByteArrayOutputStream
java.lang.Object
java.io.OutputStream
com.yubico.yubikit.core.util.ZeroingByteArrayOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with the default initial capacity of 32 bytes.ZeroingByteArrayOutputStream(int initialCapacity) Creates a new instance with the specified initial capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Zeros the internal buffer.voidreset()Zeros the internal buffer contents and resets the position to 0.intsize()Returns the current number of bytes written.byte[]Returns a copy of the data written so far.voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwriteTo(OutputStream out) Writes the contents to another stream.Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
ZeroingByteArrayOutputStream
public ZeroingByteArrayOutputStream()Creates a new instance with the default initial capacity of 32 bytes. -
ZeroingByteArrayOutputStream
public ZeroingByteArrayOutputStream(int initialCapacity) Creates a new instance with the specified initial capacity.
-
-
Method Details
-
write
public void write(int b) - Specified by:
writein classOutputStream
-
write
public void write(byte[] b, int off, int len) - Overrides:
writein classOutputStream
-
toByteArray
public byte[] toByteArray()Returns a copy of the data written so far. -
size
public int size()Returns the current number of bytes written. -
reset
public void reset()Zeros the internal buffer contents and resets the position to 0. -
close
public void close()Zeros the internal buffer. Idempotent.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-
writeTo
Writes the contents to another stream.- Throws:
IOException
-