title: How Buffer Streams works internally in Java
body: <p>I'm reading about <a href="https://docs.oracle.com/javase/tutorial/essential/io/buffers.html" rel="nofollow noreferrer">Buffer Streams</a>. I searched about it and found many answers that clear my concepts but still have little more questions.</p>
  
  <p>After searching, I have come to know that, Buffer is temporary memory(RAM) which helps program to read data quickly instead hard disk. and when Buffers empty then native <code>input API is called</code>.</p>
  
  <p>After reading little more I got answer <a href="https://stackoverflow.com/questions/15984789/what-exactly-does-stream-and-buffer-mean-in-java-i-o">from here</a> that is.</p>
  
  <blockquote>
    <p>Reading data from disk byte-by-byte is very inefficient. One way to
    speed it up is to use a buffer: instead of reading one byte at a time,
    you read a few thousand bytes at once, and put them in a buffer, in
    memory. Then you can look at the bytes in the buffer one by one.</p>
  </blockquote>
  
  <p>I have two confusion, </p>
  
  <p>1: How/Who data filled in Buffers? (native API how?) as quote above, who filled thousand bytes at once? and it will consume same time. Suppose I have 5MB data, and 5MB loaded once in Buffer in 5 Seconds. and then program use this data from buffer in 5 seconds. Total 10 seconds. But if I skip buffering, then program get direct data from hard disk in 1MB/2sec same as 10Sec total. Please clear my this confusion.</p>
  
  <p>2: The second one how this line works</p>
  
  <p><code>BufferedReader inputStream = new BufferedReader(new FileReader("xanadu.txt"));</code></p>
  
  <p>As I'm thinking FileReader write data to buffer, then BufferedReader read data from buffer memory? Also explain this.</p>
  
  <p>Thanks.</p>