title: Split String By Character
body: <p>I have a case in which I'm doing the following:</p>
  
  <pre><code>final String[] columns = row.split(delimiter.toString());
  </code></pre>
  
  <p>Where <code>delimiter</code> is a Character.</p>
  
  <p>This works fine when I need to split based on tabs by providing <code>\t</code> as the delimiter. However, when I want to split on a pipe, I pass in a delimiter of <code>|</code> and this does not work as expected.</p>
  
  <p>I've read several posts about how <code>|</code> is a special character which means null or empty therefore it splits on every character it encounters, though, I don't want this behavior.</p>
  
  <p>I could do a simple check in my code for this pipe case and get around the issue:</p>
  
  <pre><code>if ("|".equals(delimiter.toString())) {
      columns = row.split("\\" + delimiter.toString());
  }
  else {
      columns = row.split(delimiter.toString());
  } 
  </code></pre>
  
  <p>But I didn't know if there was an easier way to get around this. Also, are there any other special characters that act like the <code>|</code> does that I need to take into account?</p>