FilterInputStream FilterOutputStream都是装饰器模式中的Decorator抽象装饰角色
他们继承了各自的抽象构建InputStream 和OutputStream

他们内部都包含了一个抽象构建

FilterInputStream FilterOutputStream 既然作为抽象的装饰器角色存在
所以他们也不太可能有什么实质性的方法
FilterInputStream中的所有方法 都使用的是内部的in来转发调用

FilterOutputStream也是一样,几乎所有的请求都是转发给了内部的out对象

不过有一个特殊的地方
内部的三个参数版本的write 并没有调用out对象的三个参数的write
仍旧是调用一个参数的write
注释中有明确提示Subclasses of FilterOutputStream should provide a more efficient implementation of this method.
子类应该重写此方法以提供更好地实现

转载务必注明出处:程序员潇然,疯狂的字节X,https://crazybytex.com/thread-147-1-1.html
|