title: Word processing performance: ArrayList.toArray() or StringBuilder.split()
body: <p>I am reading a newline-separated text file into a <code>String</code>-array. </p>
  
  <p>Since I know the delimiter will always be <code>\n</code>, I should be able to append each word to a StringBuilder, then split it using the delimiter.</p>
  
  <p>Simply put, which method should I use and why?</p>
  
  <p><strong>Method A:</strong><br />
  1. Create an ArrayList (or another more suited Collection)<br />
  2. Append each row to the list<br />
  3. Return <code>list.toArray()</code><br ></p>
  
  <p><strong>Method B:</strong><br />
  1. Create a StringBuilder<br />
  2. Append each row to the builder<br />
  3. Return <code>builder.split("\n")</code></p>