It looks like a subtle mistake. If you reduce the sizey buffer, you will get an IOException
public static void main(String[] args) throws IOException { InputStream reader = new ByteArrayInputStream(new byte[]{1, 2, 3, 4, 5, 6, 7, 8}); BufferedInputStream bis = new BufferedInputStream(reader, 3); bis.mark(1); bis.read(); bis.read(); bis.read(); bis.read(); bis.reset(); System.out.println((char)bis.read()); }
Philippe marschall
source share