将字节写入 OutputStream

一次一个字节地将字节写入 OutputStream

OutputStream stream = object.getOutputStream();

byte b = 0x00;
stream.write( b );

写一个字节数组

byte[] bytes = new byte[] { 0x00, 0x00 };

stream.write( bytes );

写一个字节数组的一部分

int offset = 1;
int length = 2;
byte[] bytes = new byte[] { 0xFF, 0x00, 0x00, 0xFF };

stream.write( bytes, offset, length );