Package io.fusionauth.http.io
Class FastByteArrayOutputStream
java.lang.Object
java.io.OutputStream
io.fusionauth.http.io.FastByteArrayOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
A simple fast byte array output stream. This does no checks and has no synchronization. It simply jams data in an array and resizes in
increments (set in the constructor).
- Author:
- Brian Pontarelli
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]protected intprotected int -
Constructor Summary
ConstructorsConstructorDescriptionFastByteArrayOutputStream(int size, int growthRate) Creates a newFastByteArrayOutputStreamwith the given size. -
Method Summary
Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Field Details
-
buffer
protected byte[] buffer -
count
protected int count -
growthRate
protected int growthRate
-
-
Constructor Details
-
FastByteArrayOutputStream
public FastByteArrayOutputStream(int size, int growthRate) Creates a newFastByteArrayOutputStreamwith the given size.- Parameters:
size- The initial size of the buffer.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-
reset
public void reset()Resets this output stream by setting the count to 0. -
size
public int size()- Returns:
- The number of bytes that have been written to the output stream.
-
bytes
public byte[] bytes()- Returns:
- The byte array (directly without copying).
-
write
public void write(int b) - Specified by:
writein classOutputStream
-
write
public void write(byte[] source, int offset, int length) - Overrides:
writein classOutputStream
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-