BufferedInputStream
2016-10-11 10:13:12 0 举报
BufferedInputStream是Java中的一个输入流类,它继承自FilterInputStream。该类的主要作用是为读取数据提供缓冲功能,从而提高读取效率。当使用BufferedInputStream读取文件时,系统会将文件内容缓存到内存中,这样在读取文件时就不需要频繁地访问磁盘,减少了IO操作的次数,提高了程序的运行速度。同时,BufferedInputStream还提供了mark()和reset()方法,用于标记当前读取位置,以便后续可以恢复到该位置继续读取。总之,BufferedInputStream是一个实用的输入流类,能够提高程序的执行效率。
作者其他创作
大纲/内容
BufferedOutputStream
buf[] 缓冲数据count 缓冲区有效字节
write()flushBuffer()
pos-markpos 未使用的从头覆盖bufferpos =pos-markposmarkpos = 0
pos=0 mark=-1从头填充
buffer.pos + 读取长度为buffer.length-pos
poscount
len marklimit
posbuf.len
markpos0
read
BufferedInputStream
buf[] 缓冲数据bufUpdater 数组原子更新defaultBufferSize 默认8192字节count 缓冲区有效字节pos 当前缓冲区索引 还未做位置markpos 当前缓冲区的标记位置marklimit 标记的最大值
read()read1()fill() 填充数据mark()reset()getInIfOpengetBufIfOpen
fill
0 条评论
下一页