Java - Bytearrayoutputstream: SN Methods With Desc Ription Public Void Reset
Java - Bytearrayoutputstream: SN Methods With Desc Ription Public Void Reset
http://www.tuto rialspo int.co m/java/java_byte arrayo utputstre am.htm Co pyrig ht © tuto rials po int.co m
T he ByteArrayOutputStream class stream creates a buffer in memory and all the data sent to the stream is stored
in the buffer. T here are following forms of constructors to create ByteArrayOutputStream objects
Once you have ByteArrayOutputStream object in hand then there is a list of helper methods which can be used
to write the stream or to do other operations on the stream.
Example:
Following is the example to demonstrate ByteArrayOutputStream and ByteArrayOutputStream
import java.io.*;
while( bOutput.size()!= 10 ) {
// Gets the inputs from the user
bOutput.write(System.in.read());
}
byte b [] = bOutput.toByteArray();
System.out.println("Print the content");
for(int x= 0 ; x < b.length; x++) {
//printing the characters
System.out.print((char)b[x] + " ");
}
System.out.println(" ");
int c;
asdfghjkly
Print the content
a s d f g h j k l y
Converting characters to Upper case
A
S
D
F
G
H
J
K
L
Y