Java BufferedOutputStream write(byte[] b, int off, int len) method example

HQ ┬╗ Java Tutorial ┬╗ java.io ┬╗ BufferedOutputStream ┬╗ write(byte[] b, int off, int len) method example
Java BufferedOutputStream write(byte[] b, int off, int len) method example 2018-02-16T07:26:35+00:00

java.io.BufferedOutputStream write(byte[] b, int off, int len)

Description

On this document we will be showing a java example on how to use the write(byte[] b, int off, int len) method of BufferedOutputStream Class. This method writes len bytes from the specified byte array starting at offset off to this buffered output stream.

Ordinarily this method stores bytes from the given array into this stream’s buffer, flushing the buffer to the underlying output stream as needed. If the requested length is at least as large as this stream’s buffer, however, then this method will flush the buffer and write the bytes directly to the underlying output stream. Thus redundant BufferedOutputStreams will not copy data unnecessarily.

Override by:

write in class FilterOutputStream

Throws:

  • IOException – If an I/O error occurs

Method Syntax

public void write(byte[] b, int off, int len)
throws IOException

Method Argument

Data Type Parameter Description
byte[] b the data
int off the start offset in the data.
int len the number of bytes to write.

Method Returns

This method returns void.

Compatibility

Requires Java 1.0 and up

Java BufferedOutputStream write(byte[] b, int off, int len) Example

Below is a java code demonstrates the use of write(byte[] b, int off, int len) method of BufferedOutputStream class. The example presented might be simple however it shows the behaviour of the write(byte[] b, int off, int len).

Sample Output

Below is the sample output when you run the above example.

java BufferedOutputStream write(byte[] b, int off, int len) example output

Contact Info

Singapore

Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close