ByteArrayInputStream close() in Java

close(): This method is available in java.io.ByteArrayInputStream class of Java.

Syntax:

void java.io.ByteArrayInputStream.close() throws IOException

Closing a ByteArrayInputStream has no effect.

The methods in this class can be called after the stream has been closed without generating an IOException.

Parameters: NA

Returns: NA

Throws:

IOException - if an I/O error occurs.

Approach

Java

import java.io.ByteArrayInputStream;
import java.io.IOException;

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

        byte buf[] = { 1, 2, 3, 4 };
        ByteArrayInputStream byteArrayInputStream =
new ByteArrayInputStream(buf);

        System.out.println("Closing the byteBuffer");
        byteArrayInputStream.close();
    }

}

Output:

Closing the byteBuffer


No comments:

Post a Comment