PushbackInputStream.mark(int readlimit) has the following syntax.
public void mark(int readlimit)
In the following code shows how to use PushbackInputStream.mark(int readlimit) method.
/*from w ww .jav a2s . c om*/ import java.io.*; public class Main { public static void main(String[] args) { byte[] arrByte = new byte[1024]; byte[] byteArray = new byte[]{'j', 'a', 'v', 'a', '2','s','.','c','o','m'}; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is); try { for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } pis.mark(5); } catch (Exception ex) { ex.printStackTrace(); } } }
The code above generates the following result.