Java BufferedOutputStream .write (int b)
Syntax
BufferedOutputStream.write(int b) has the following syntax.
public void write(int b) throws IOException
Example
In the following code shows how to use BufferedOutputStream.write(int b) method.
/*from w w w . j a v a 2 s . c o m*/
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
public class Main {
public static void main(String[] args) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
int b = 87;
bos.write(b);
bos.flush();
byte[] bytes = baos.toByteArray();
System.out.println(bytes[0]);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »