All About Class ByteArrayOutputStream in Java

0
30
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

ByteArrayOutputStream in Java
 ByteArrayOutputStream in Java

 ByteArrayOutputStream in Java:

ByteArrayOutputStream class implements an output stream where the data is written or stored 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 synchronized void reset();
public int size();
public synchronized byte[] toByteArray();
public String toString();
public String toString(String enc) throws UnsupportedEncodingException;
public String toString(int hiBytes);
public synchronized void write(byte b[],int offSet,int length);
public synchronized void write(int b);
public synchronized void writeTo(OutputStream out) throws IOException;
}
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

LEAVE A REPLY

Please enter your comment!
Please enter your name here