title: Split and remove new line
body: <p>I try to split text by comma and add to list each one. Text sample:</p>
  <blockquote>
  <p>user 1 , role 1</p>
  <p>user 2 , role 2<br />
  user 3 , role 3</p>
  <pre><code> user 4 , role 4
  
   user 5 , role 5
  </code></pre>
  </blockquote>
  <p>Function:</p>
  <pre><code>private Map&lt;Integer, List&lt;String&gt;&gt; map = new HashMap&lt;Integer, List&lt;String&gt;&gt;();
  public String splitString(String sentence) {
      List&lt;String&gt; list;
      String[] dividedByNewLine = sentence.split(&quot;\n&quot;);
      for (int i = 0; i &lt; dividedByNewLine.length; i++) {
              String[] divideByComma = dividedByNewLine[i].split(&quot;,&quot;);
              list = new ArrayList&lt;String&gt;();
              for (int j = 0; j &lt; divideByComma.length; j++) {
                  list.add(divideByComma[j].trim());
              }
              if (!list.isEmpty()) {
                  map.put(i, list);
              }
              System.out.println(map.get(i));
         
      }
  
      return null;
  }
  </code></pre>
  <p>But function build list like that:</p>
  <blockquote>
  <p>[user 1 , role 1]</p>
  <p>[]</p>
  <p>[user 2 , role 2]</p>
  <p>[user 3 , role 3]</p>
  <p>[]</p>
  <p>[user 4 , role 4]</p>
  <p>[]</p>
  <p>[user 5 , role 5]</p>
  </blockquote>
  <p>How can I delete &quot;[]&quot; in list?</p>