62,615
社区成员
发帖
与我相关
我的任务
分享
public class TestBufferedInputStream {
public static void main(String args[]) {
try {
int c = 0;
byte [] bytes = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
BufferedInputStream bis = new BufferedInputStream(bais);
bis.read();
bis.mark(3);
for(int i = 0;i<6&&(c = bis.read()) != -1;i++){
System.out.print(c);
}
System.out.println();
bis.reset();
for(int i = 0;i<6&&(c = bis.read()) != -1;i++){
System.out.print(c);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void mark(int readAheadLimit) {
mark = pos;
}
public synchronized void mark(int readlimit) {
marklimit = readlimit;
markpos = pos;
}