title: Using BufferedReader to read and store large text file into a String
body: <blockquote>
  <p><strong>Possible Duplicate:</strong><br />
  <a href="https://stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file">How to create a Java String from the contents of a file</a></p>
  </blockquote>
  
  <p>I am using a <code>BufferedReader</code> to read a large text file and want to store the entirety of what the reader reads into a <code>String</code>. This does not seem to be working correctly as when I print out the <code>String</code>, it seems as if it only grabbed the last portion of the file. Am I doing something wrong here?</p>
  <pre class="lang-java prettyprint-override"><code>try {
      String str = &quot;&quot;;
      BufferedReader fileReader = new BufferedReader(new FileReader(args[2]));
      while (fileReader.ready()) {
          str += (char) fileReader.read();
      }
      System.out.println(str);
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>