Java中的 FilterInputStream简介_动力节点Java学院整理
FilterInputStream介绍
FilterInputStream的作用是用来“封装其它的输入流,并为它们提供额外的功能”。它的常用的子类有BufferedInputStream和DataInputStream。
BufferedInputStream的作用就是为“输入流提供缓冲功能,以及mark()和reset()功能”。
DataInputStream是用来装饰其它输入流,它“允许应用程序以与机器无关方式从底层输入流中读取基本Java数据类型”。应用程序可以使用DataOutputStream(数据输出流)写入由DataInputStream(数据输入流)读取的数据。
FilterInputStream源码(基于jdk1.7.40)
packagejava.io;
publicclassFilterInputStreamextendsInputStream{
protectedvolatileInputStreamin;
protectedFilterInputStream(InputStreamin){
this.in=in;
}
publicintread()throwsIOException{
returnin.read();
}
publicintread(byteb[])throwsIOException{
returnread(b,0,b.length);
}
publicintread(byteb[],intoff,intlen)throwsIOException{
returnin.read(b,off,len);
}
publiclongskip(longn)throwsIOException{
returnin.skip(n);
}
publicintavailable()throwsIOException{
returnin.available();
}
publicvoidclose()throwsIOException{
in.close();
}
publicsynchronizedvoidmark(intreadlimit){
in.mark(readlimit);
}
publicsynchronizedvoidreset()throwsIOException{
in.reset();
}
publicbooleanmarkSupported(){
returnin.markSupported();
}
}
以上所述是小编给大家介绍的Java中的FilterInputStream简介,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短