title: How the buffer byte array is continuously filling while streaming?
body: <p>The below  piece of code  using  to reading for <code>Files</code> </p>
  
  <pre><code> int bytesRead;
   byte[] bytes = new byte[1000];  //buffer
   FileInputStream fis = new FileInputStream(uploadedFile);
  
      while ((bytesRead = fis.read(bytes)) != -1) {
            fis.read(bytes, 0, bytesRead);
      }
  
  fis.close();
  </code></pre>
  
  <p>As per <a href="http://docs.oracle.com/javase/6/docs/api/java/io/FileInputStream.html#read%28byte%5B%5D%29" rel="nofollow">api of read()  method</a> </p>
  
  <blockquote>
    <p>Reads up to b.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.</p>
  </blockquote>
  
  <p>There is no where specified that it refills the <code>bytes</code> array,but the stream filling the <code>array</code>  until the <code>file</code> successfully <code>read.</code>.</p>
  
  <p>But how the internally it's maintaining to get this  magic done  ?? </p>
  
  <p>I saw source code or read method </p>
  
  <pre><code>public int More ...read(byte b[]) throws IOException {
  214        return readBytes(b, 0, b.length);
  215    }
  </code></pre>
  
  <p>and <code>readBytes</code>'s source code  is </p>
  
  <pre><code>200    private native int More ...readBytes
                  (byte b[], int off, int len) throws IOException;
  </code></pre>
  
  <p>There is noting mentioned that how <code>bytes</code> ..  </p>
  
  <p>I uploaded a 500MB file without any problem,with allocation that <code>1000</code> bytes <code>array</code>. </p>