BufferedOutputStream write(int) in Java

write(int): This method is available in the java.io.BufferedOutputStream class of Java.

Syntax:

void java.io.BufferedOutputStream.write(int b) throws IOException

This method takes one argument. This method writes the specified byte to this buffered output stream.

Parameters: One parameter is required for this method.

b: the byte to be written.

Returns: NA

Throws:

IOException - if an I/O error occurs.

Approach

Java

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class BufferedOutputStreamwrite {
    public static void main(String[] args) throws IOException {

        FileOutputStream fileOutputStream =
new FileOutputStream("D:\\hello.txt");

        BufferedOutputStream bufferedOutputStream =
new BufferedOutputStream(fileOutputStream);

        int b = 10;
        bufferedOutputStream.write(b);

        System.out.println("Write Success");

        bufferedOutputStream.close();
    }
}

Output:

Write Success


No comments:

Post a Comment