Java Language InputStreams and OutputStreams Writing bytes to an OutputStream

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Writing bytes to an OutputStream one byte at a time

OutputStream stream = object.getOutputStream();

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

Writing a byte array

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

stream.write( bytes );

Writing a section of a byte array

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

stream.write( bytes, offset, length );


Got any Java Language Question?