public final class UnsynchronizedByteArrayOutputStream extends AbstractByteArrayOutputStream
AbstractByteArrayOutputStream without any concurrent thread safety.
To build an instance, see UnsynchronizedByteArrayOutputStream.Builder.
| Modifier and Type | Class and Description |
|---|---|
static class |
UnsynchronizedByteArrayOutputStream.Builder
Builds a new
UnsynchronizedByteArrayOutputStream instance. |
| Constructor and Description |
|---|
UnsynchronizedByteArrayOutputStream()
|
UnsynchronizedByteArrayOutputStream(int size)
|
| Modifier and Type | Method and Description |
|---|---|
static UnsynchronizedByteArrayOutputStream.Builder |
builder()
Constructs a new
UnsynchronizedByteArrayOutputStream.Builder. |
void |
reset() |
int |
size()
Returns the current size of the byte array.
|
static java.io.InputStream |
toBufferedInputStream(java.io.InputStream input)
Fetches entire contents of an
InputStream and represent same data as result InputStream. |
static java.io.InputStream |
toBufferedInputStream(java.io.InputStream input,
int size)
Fetches entire contents of an
InputStream and represent same data as result InputStream. |
byte[] |
toByteArray()
Gets the current contents of this byte stream as a byte array.
|
java.io.InputStream |
toInputStream()
Gets the current contents of this byte stream as an Input Stream.
|
void |
write(byte[] b,
int off,
int len) |
int |
write(java.io.InputStream in)
Writes the entire contents of the specified input stream to this
byte stream.
|
void |
write(int b) |
void |
writeTo(java.io.OutputStream out)
Writes the entire contents of this byte stream to the
specified output stream.
|
close, toString, toString, toString@Deprecated public UnsynchronizedByteArrayOutputStream()
builder(), UnsynchronizedByteArrayOutputStream.Builder, and UnsynchronizedByteArrayOutputStream.Builder.get().@Deprecated public UnsynchronizedByteArrayOutputStream(int size)
builder(), UnsynchronizedByteArrayOutputStream.Builder, and UnsynchronizedByteArrayOutputStream.Builder.get().size - the initial sizejava.lang.IllegalArgumentException - if size is negativepublic static UnsynchronizedByteArrayOutputStream.Builder builder()
UnsynchronizedByteArrayOutputStream.Builder.UnsynchronizedByteArrayOutputStream.Builder.public static java.io.InputStream toBufferedInputStream(java.io.InputStream input)
throws java.io.IOException
InputStream and represent same data as result InputStream.
This method is useful where,
toByteArray(), since it avoids unnecessary allocation and copy of byte[].BufferedInputStream.input - Stream to be fully buffered.java.io.IOException - if an I/O error occurs.public static java.io.InputStream toBufferedInputStream(java.io.InputStream input,
int size)
throws java.io.IOException
InputStream and represent same data as result InputStream.
This method is useful where,
toByteArray(), since it avoids unnecessary allocation and copy of byte[].BufferedInputStream.input - Stream to be fully buffered.size - the initial buffer sizejava.io.IOException - if an I/O error occurs.public void reset()
reset in class AbstractByteArrayOutputStreamByteArrayOutputStream.reset()public int size()
AbstractByteArrayOutputStreamsize in class AbstractByteArrayOutputStreampublic byte[] toByteArray()
AbstractByteArrayOutputStreamtoByteArray in class AbstractByteArrayOutputStreamByteArrayOutputStream.toByteArray()public java.io.InputStream toInputStream()
AbstractByteArrayOutputStreamthis stream,
avoiding memory allocation and copy, thus saving space and time.toInputStream in class AbstractByteArrayOutputStreamByteArrayOutputStream.toByteArray(),
AbstractByteArrayOutputStream.reset()public void write(byte[] b,
int off,
int len)
write in class AbstractByteArrayOutputStreampublic int write(java.io.InputStream in)
throws java.io.IOException
AbstractByteArrayOutputStreamwrite in class AbstractByteArrayOutputStreamin - the input stream to read fromjava.io.IOException - if an I/O error occurs while reading the input streampublic void write(int b)
write in class AbstractByteArrayOutputStreampublic void writeTo(java.io.OutputStream out)
throws java.io.IOException
AbstractByteArrayOutputStreamwriteTo in class AbstractByteArrayOutputStreamout - the output stream to write tojava.io.IOException - if an I/O error occurs, such as if the stream is closedByteArrayOutputStream.writeTo(OutputStream)Copyright © 2010 - 2023 Adobe. All Rights Reserved