Javatpoint Logo
Javatpoint Logo

Java ByteArrayOutputStream toByteArray() method

The toByteArray() method of Java ByteArrayOutputStream class is used to create a newly allocated byte array with the size as the current size of this output stream.

Syntax:

Returns

The toByteArray() method returns the current contents of this output stream as a byte array.

Example 1

Test it Now

Output:

65
66
67
68
69

Example 2

Test it Now

Output:

75
76
77
78
79






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA