title: Reading a file vs loading a file into main memory from disk for processing
body: <p>how do I load a file into main memory?</p>
  
  <p>I read the files using,
  I use </p>
  
  <pre><code>BufferReader buf = new BufferedReader(FileReader());
  </code></pre>
  
  <p>I presume that this is reading the file line by line from the disk. What is the advantage of this?</p>
  
  <p>What is the advantage of loading the file directly into memory?
  How do we do that in Java?</p>
  
  <p>I found some examples on <code>Scanner</code> or <code>RandomAccessFile</code> methods. Do they load the files into memory? Should I use them? Which of the two should I use ? </p>
  
  <p>Thanks in advance!!!</p>