title: Java: String split(): I want it to include the empty strings at the end
body: <p>I have the following String:</p>
  
  <pre><code>String str = "\nHERE\n\nTHERE\n\nEVERYWHERE\n\n";
  </code></pre>
  
  <p>If you just print this, it would output like this (Of course the <code>\n</code> wouldn't be "literally" printed):</p>
  
  <pre><code>\n
  HERE\n
  \n
  THERE\n
  \n
  EVERYWHERE\n
  \n
  \n
  </code></pre>
  
  <p>When I call the method <code>split("\n")</code>, I want to get all strings between the new line (<code>\n</code>) characters even empty strings at the end.</p>
  
  <p>For example, if I do this today:</p>
  
  <pre><code>String strArray[] = str.split("\n");
  
  System.out.println("strArray.length - " + strArray.length);
  for(int i = 0; i &lt; strArray.length; i++)
      System.out.println("strArray[" + i + "] - \"" + strArray[i] + "\"");
  </code></pre>
  
  <p>I want it to print out like this (Output A):</p>
  
  <pre><code>strArray.length - 8
  strArray[0] - ""
  strArray[1] - "HERE"
  strArray[2] - ""
  strArray[3] - "THERE"
  strArray[4] - ""
  strArray[5] - "EVERYWHERE"
  strArray[6] - ""
  strArray[7] - ""
  </code></pre>
  
  <p>Currently, it prints like this (Output B), and any ending empty strings are skipped:</p>
  
  <pre><code>strArray.length - 6
  strArray[0] - ""
  strArray[1] - "HERE"
  strArray[2] - ""
  strArray[3] - "THERE"
  strArray[4] - ""
  strArray[5] - "EVERYWHERE"
  </code></pre>
  
  <p>How do I make the <code>split()</code> method include the empty strings like in Output A? I, of course, could write a multi-line piece of code, but wanted to know, before I waste my time trying to implement that, if there was a simple method or an extra two or so lines of code to help me. Thanks!</p>