简体   繁体   中英

what about one BufferedOutputStream wrap another BufferedOutputStream?

what about one BufferedOutputStream wrap another BufferedOutputStream? this question is simple. but confused. As the following code,

        OutputStream file = new FileOutputStream("test.txt");
        OutputStream buffer = new BufferedOutputStream(file);
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(buffer);      //wrap buffer twice
        OutputStream outputStream = new ObjectOutputStream(bufferedOutputStream);  // wrap as ObjectOutputStream
        BufferedOutputStream bufferedOutputStream1 = new BufferedOutputStream(outputStream); //wrap back as BufferedOutputStream
        ObjectOutput output = new ObjectOutputStream(bufferedOutputStream1);

What about it? Question?

If you're asking whether an inefficiency is introduced, the answer is 'no'. The code is optimised to handle that case, or rather the case where the transfer size >= the buffer size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM