Java ByteArrayOutputStream .toString ()
Syntax
ByteArrayOutputStream.toString() has the following syntax.
public String toString()
Example
In the following code shows how to use ByteArrayOutputStream.toString() method.
/*w w w . ja v a 2s.c o m*/
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
byte[] bs = { 65, 66, 67, 68, 69 };
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(bs);
String str = baos.toString();
System.out.println(str);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »