ByteArrayOutputStream (Java SE 26 & JDK 26)
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
-
Field Summary
Fields
protected byte[]The buffer where data is stored.
protected intThe number of valid bytes in the buffer.
-
Constructor Summary
Constructors
Creates a new
ByteArrayOutputStream.ByteArrayOutputStream(int size) Creates a new
ByteArrayOutputStream, with a buffer capacity of the specified size, in bytes. -
Method Summary
voidclose()Closing a
ByteArrayOutputStreamhas no effect.voidreset()Resets the
countfield of thisByteArrayOutputStreamto zero, so that all currently accumulated output in the output stream is discarded.intsize()Returns the current size of the buffer.
byte[]Creates a newly allocated byte array.
toString()Converts the buffer's contents into a string decoding bytes using the default charset.
toString(int hibyte) Converts the buffer's contents into a string by decoding the bytes using the named
charset.Converts the buffer's contents into a string by decoding the bytes using the specified
charset.voidwrite(byte[] b, int off, int len) Writes
lenbytes from the specified byte array starting at offsetoffto thisByteArrayOutputStream.voidwrite(int b) Writes the specified byte to this
ByteArrayOutputStream.voidwriteBytes(byte[] b) Writes the complete contents of the specified byte array to this
ByteArrayOutputStream.voidWrites the complete contents of this
ByteArrayOutputStreamto the specified output stream argument, as if by calling the output stream's write method usingout.write(buf, 0, count).Methods declared in class OutputStream
flush, nullOutputStream, writevoidFlushes this output stream and forces any buffered output bytes to be written out.
Returns a new
OutputStreamwhich discards all bytes.voidWrites
b.lengthbytes from the specified byte array to this output stream.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitCreates and returns a copy of this object.
booleanIndicates whether some other object is "equal to" this one.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.intReturns a hash code value for this object.
final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
buf
-
count
-
-
Constructor Details
-
ByteArrayOutputStream
-
ByteArrayOutputStream
-
-
Method Details
-
write
-
write
-
writeBytes
-
writeTo
-
reset
-
toByteArray
-
size
-
toString
-
toString
-
toString
-
toString
-
close
-