BufferedInputStream and BufferedOutputStream in java

In the previous post, we have seen FileInputStream and FileOutputStream. In this post, we will look at BufferedInputStream and BufferedOutputStream in java.

Let’s start with BufferedOutputStream class.

BufferedOutputStream class:

BufferedOutputStream class uses an internal buffer to store the data first. Rather than writing one byte at a time to the destination file, stored data in a buffer will be written at a time. It is not required to make a system call for each byte written, hence speed up writing.

This is typically much faster , can be used for disk access and large amount of data. To add buffering to outputStream , simply add it through BufferedOutputStream. Let’s look at the example below for understanding.

Output: Write task successful


BufferedInputStream class is used to provide buffering to inputStream. Instead of reading one byte at a time, it can read a large block of data. It improves the reading performance.

Example of BufferedInputStream:

Output: My laptop is working good
Ask Question
If you have any question, you can go to menu ‘Features -> Q&A forum-> Ask Question’.Select the desired category and post your question.



FileInputStream and FileOutputStream in java
CharArrayWriter Class in java
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...

1 Response

  1. August 8, 2015

    […] the previous post, we have seen BufferedInputStream and BufferedOutputStream. In this post, we will CharArrayWriter […]