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