ByteArrayOutputStream size() in Java

size(): This method is available in the java.io.ByteArrayOutputStream  class of Java.

Syntax:

int java.io.ByteArrayOutputStream.size()

This method returns the current size of the buffer.

Parameters: NA

Returns: the value of the count field, which is the number of valid bytes in this output stream.

Exceptions: NA

Approach

Java

import java.io.ByteArrayOutputStream;
import java.io.IOException;

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

        int size = 5;
        ByteArrayOutputStream byteArrayOutputStream =
new ByteArrayOutputStream(size);

        System.out.println(byteArrayOutputStream.size());
        byteArrayOutputStream.close();
    }
}

Output:

0


No comments:

Post a Comment