CharArrayReader mark(int) in Java

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

Syntax:

void java.io.CharArrayReader.mark(int readAheadLimit) throws IOException

This method takes one argument. This method marks the present position in the stream.

Note: Subsequent calls to reset() will reposition the stream to this point.

Parameters: One parameter is required for this method.

readAheadLimit: Limit the number of characters that may be read while still preserving the mark.

Returns: NA

Throws:

IOException - If an I/O error occurs

Approach

Java

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

public class CharArrayReadermark {

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

        int readAheadLimit = 1;
        charArrayReader.mark(readAheadLimit);

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

    }
}

Output:

Successfully mark


No comments:

Post a Comment