关于java的IO流对InputStream一定要用BufferedInputStream
对OuputStream一定要用BufferedOutputStream
对Reader一定要用BufferedReader
对Writer一定要用BufferedWriter是不是后者的效率要比前者好??BufferedInputStream bis = new BufferedInputStream(new InputStream());

解决方案 »

  1.   

    缓冲处理在处理大批量操作效率更高些,和CPU有个缓冲池是一个道理的。
      

  2.   

    这不是缓冲的问题,
    对于以byte形式读写的流,都用stream命名
    对于以word形式读写的流,都用buffer命名其实java在io问题上使用了“Decorator”的设计模式,就是用一个类作为另一个类的输入参数。例如:buffer类可以接受网络,文件等形式传入的信息。如果使用“Decorator”的设计模式,则可以使用组合的形式实现buffer+file,buffer+web,buffer+web+file,buffer+file+web的4种情况的读写,而并不需要写7个类实现,现在只需要3个类即可,当数量越大,越能体现此模式的好处。
      

  3.   

    hehe...不是缓冲的问题?
        BufferedXXX确实是增加了对stream的缓冲能力。
        不是一定要用到BufferedXXX,但是使用BufferedXXX对stream进行包装,将会使你的程序运行效率大大增加,尤其是在Web app的应用中(在这些应用中,信息的传输是极耗时间的)。
        至于congliu朋友的叙述似乎有些问题,如果论命名byte形式的流均为byte stream,字节流;char形式的流均为char stream,字符流。另外,使用装饰模式就是包装了基本的字节流使之拥有诸如文件操作、字符流、缓冲等强大的功能,并不与缓冲说明相冲突。缓冲是说经过BufferedXXX包装了的流将具有缓冲功能,所以一个是功能说明,一个则是实现机制罢了。
    @.@||~
      

  4.   

    哈哈。我觉得可以说是缓冲,因为如果用BufferedReader的话可以有readLine()方法
    这样有助于我们对这个流的使用。封装后的效果!
      

  5.   

    看一下jdk的解释吧
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the  and reset methods. When the BufferedInputStream is created, an internal buffer array is created. As bytes from the stream are read or skipped, the internal buffer is refilled as necessary from the contained input stream, many bytes at a time. The  operation remembers a point in the input stream and the reset operation causes all the bytes read since the most recent  operation to be reread before new bytes are taken from the contained input stream.就是在里面添加了一个数组buffer[],用来缓存要读写的数据。
      

  6.   

    当然了,后者加了缓冲,效率高,因为它每次可以读去一行,如BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
      

  7.   

    congliu回答的是InputStreamReader和OutputStreamReader的作用啦
      

  8.   

    可以不用Buffered....啊,只要你不嫌慢
      

  9.   

    hehe...
        我到认为congliu回答的应该是实现的方式,而不是实现的作用。他的作用应该是缓冲,并使用装饰模式实现之。@.@||~