ByteArrayOutputStream.write(int b) has the following syntax.
public void write(int b)
In the following code shows how to use ByteArrayOutputStream.write(int b) method.
// w ww . j a v a2 s. c o m import java.io.ByteArrayOutputStream; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); // write byte array to the output stream baos.write(55); // converts the byte to the default charset value String str = baos.toString(); // prints the string System.out.println(str); } }
The code above generates the following result.