CharArrayReader reset() in Java

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

Syntax:

void java.io.CharArrayReader.reset() throws IOException

This method resets the stream to the most recent mark, or to the beginning if it has never been marked.

Parameters: NA

Returns: NA

Throws:

IOException - If an I/O error occurs

Approach

Java

import java.io.CharArrayReader;
import java.io.IOException;

public class CharArrayReaderreset {

    public static void main(String[] args) throws IOException {
        char buf[] = { 'a', 'b', 'c', 'd' };
        CharArrayReader charArrayReader =
new CharArrayReader(buf);

        charArrayReader.reset();
        System.out.println("Successfully reset");
        charArrayReader.close();

    }
}

Output:

Successfully reset


No comments:

Post a Comment