All About Class ByteArrayOutputStream in Java



ByteArrayOutputStream class implements an output stream where the data is written into a byte Array.The buffer automatically grows as data written into it.

The structure of Class ByteArrayOutputStream is given as below:

public class java.io.ByteArrayOutputStream extends java.io.OutputStream{
//member elements
protected byte buf[];
//the buffer where the data is stored
protected int count;//the number of valid bytes in the buffer
//constructors:
public ByteArrayOutputStream();
///creates a new ByteArrayOutputStream to write data.
public ByteArrayOutputStream(int size);
///creates a new ByteArrayOutputStream to write data.The buffer capacity is initially 32 bytes.
//Its size increases if necessary
//Methods:
public void reset();
public int size();
public byte[] toByteArray();
public String toString();
public String toString(int hiBytes);
public void write(byte b[],int offSet,int length);
public void write(int b);
public void writeTo(OutputStream out);
}
 
All About Class ByteArrayOutputStream in Java All About Class ByteArrayOutputStream in Java Reviewed by Animesh Chatterjee on October 08, 2018 Rating: 5

No comments:

Powered by Blogger.