ByteArrayOutputStream write Example
ByteArrayOutputStream class write example. This example shows you how to use write method.
ByteArrayOutputStream class write example.public void write(byte[], int , int) Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
Here is the code
/**
* @ # Write.java
* A class reprsenting use to write method
* of ByteArrayOutputStream class in java.io package
* version 09 June 2008
* author Rose India
*/
import java.io.*;
public class Write {
public static void main(String args[]) throws Exception {
ByteArrayOutputStream oStream = new ByteArrayOutputStream();
String s = "Rose India";
byte bs[] = s.getBytes();
//Writes a byte to the byte array output stream.
oStream.write(bs, 0, 4);
System.out.println(oStream.toString());
oStream.close();
}
} |
|