Java ByteArrayOutputStream.write (int b)方法示例
ByteArrayOutputStream
的write (int b)
方法的语法如下。
public void write (int b)
示例
在下面的代码显示如何使用ByteArrayOutputStream.write(int b)
构造函数。
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);// => wW w .y Ii B AI . C om
// converts the byte to the default charset value
String str = baos.toString();
// prints the string
System.out.println(str);
}
}
上面的代码生成以下结果。
7