ByteArrayOutputStream class methods in java

java.io.ByteArrayOutputStream

This class implements an output stream in which the data is written into a byte array. The buffer automatically grows as data is written to it.

Note:

The data can be retrieved using toByteArray() and toString().


Some methods of ByteArrayOutputStream class.


close()This method closes a ByteArrayOutputStream.


reset()This method resets the count field of this ByteArrayOutputStreamto zero so that all currently accumulated output in the output stream is discarded


size()This method returns the current size of the buffer.


toByteArray()This method creates a newly allocated byte array.


toString()This method converts the buffer's contents into string decoding bytes using the platform's default character set.


toString(String)This method converts the buffer's contents into a string by decoding the bytes using the named charset.


write(int)This method writes the specified byte to this ByteArrayOutputStream.


write(byte[], int, int)This method writes len bytes from the specified byte array starting at offset off to this ByteArrayOutputStream.


writeBytes(byte[])This method writes the complete contents of the specified byte array to this ByteArrayOutputStream.


No comments:

Post a Comment