Java stream toArray() convert to a specific type of array
<p>Maybe this is very simple but I'm actually a noob on Java 8 features and don't know how to accomplish this. I have this simple line that contains the following text:</p>

<blockquote>
  <p>"Key, Name"</p>
</blockquote>

<p>and I want to convert that line into a String array, separating each value by the comma (,), however, I also want to trim every field before returning  the final array, so I did the following:</p>

<pre><code>Arrays.stream(line.split(",")).map(String::trim).toArray();
</code></pre>

<p>However, this returns an Object[] array rather than a String[] array. Upon further inspection, I can confirm that the contents are actually String instances, but the array itself is of Object elements. Let me illustrate this, this is what the debugger says of the returned object:</p>

<pre><code>Object[]:
    0 = (String) "Key"
    1 = (String) "Name"
</code></pre>

<p>As far as I can tell, the problem is in the return type of the map call, but how can I make it return a String[] array?</p>