Javatpoint Logo
Javatpoint Logo

Java OutputStream write(byte[] b) Method

The write(byte[] b) method of OutputStream class is used to write b.length bytes to this output stream from the specified byte array. In general, this method have exactly the same effect as the call write (b, 0, b. length).

Syntax

Parameters

b- It is the data

Throws:

IOException- If an I/O error occurs

Example

Output:

java

Java OutputStream write(byte[] b, int off, int len) Method

The write(byte[] b, int off, int len) method of OutputStream class is used to write len bytes starting at offset off to this output stream from the specified byte array. In general write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written, and b[off+len-1] is the last byte written by this operation.

The write method of OutputStream calls the write method of one argument on each of the bytes to be written out. If b is null, a NullPointerException is thrown.

Syntax

Parameters

b- It is the data.

off- It is the start offset in the data.

len- It is the number of bytes to write.

Throws:

IOException- If an I/O error occurs, or if the output stream is closed.

Example

Output:

javatpoint

Java OutputStream write(int b) Method

The write(int b) method of OutputStream class is used to write the specified bytes to the output stream. The bytes to be written are the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Subclass of OutputStream must provide an implementation for this method.

Syntax

Parameters

b- The byte

Throws:

IOException- If an I/O error occurs or the output stream has been closed.

Example 1

Output:

ABC
Next TopicJava OutputStream





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA