ByteArrayOutputStream (Java SE 25 & JDK 25)
- 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).
-
Field Details
-
buf
-
count
-
-
Constructor Details
-
ByteArrayOutputStream
-
ByteArrayOutputStream
-
-
Method Details
-
write
-
write
-
writeBytes
-
writeTo
-
reset
-
toByteArray
-
size
-
toString
-
toString
-
toString
-
toString
-
close
-