ByteArrayInputStream reset() in Java

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

Syntax:

void java.io.ByteArrayInputStream.reset()

This method resets the buffer to the marked position. The marked position is 0 unless another position was marked or an offset was specified in the constructor.

Parameters: NA

Returns: NA

Exceptions: NA

Approach

Java

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

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

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

        byteArrayInputStream.reset();
        System.out.println("Successfully reset");
        byteArrayInputStream.close();
    }

}

Output:

Successfully reset


No comments:

Post a Comment