Should I always wrap an InputStream as BufferedInputStream?

前端 未结 4 2182
感情败类
感情败类 2020-12-08 07:28

Does it make sense to always wrap an InputStream as BufferedInputStream, when I know whether the given InputStream is something other than buffered? For e.g:



        
4条回答
  •  情书的邮戳
    2020-12-08 07:39

    I would not do that, I would leave it at the highest abstraction level possible. If you are not going to use the mark and reset capabilities of a BufferedStream, why bother wrapping it?

    If a consumer needs it, it is better to wrap it there.

提交回复
热议问题