mark(int): This method is available in java.io.ByteArrayInputStream class of Java.
Syntax:
void java.io.ByteArrayInputStream.mark(int readAheadLimit)
This method takes one argument. This method set the currently marked position in the stream. ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by this method.
Note: The readAheadLimit for this class has no meaning.
Parameters: One parameter is required for this method.
readAheadLimit: the maximum limit of bytes that can be read before the mark position becomes invalid
Approach
Java
import java.io.ByteArrayInputStream;import java.io.IOException;public class ByteArrayInputStreammark {public static void main(String[] args) throws IOException {byte buf[] = { 1, 2, 3, 4 };ByteArrayInputStream byteArrayInputStream =new ByteArrayInputStream(buf);int readAheadLimit = 1;byteArrayInputStream.mark(readAheadLimit);System.out.println("Successfulluy Set the mark");byteArrayInputStream.close();}}
Output:
Successfulluy Set the mark
No comments:
Post a Comment