title: Cannot convert form List<File> to List<Path>
body: <p>Obviously, it's not possible to convert from List&lt;File&gt; to List&lt;Path&gt;. I was trying to do that because JFileChooser returns an array of File objects. Now, I'm just curious if there's a more elegant (functional) approach in Java than using a loop.</p>
  
  <pre><code>import java.io.File;
  import java.nio.file.Path;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  
  public class Test {
  
    public static void main(String[] args) {
      File[] array = new File[] { new File("a.txt"), new File("b.txt"),
        new File("c.txt"), new File("d.txt") };
  
      // Type mismatch: cannot convert from List&lt;File&gt; to List&lt;Path&gt;
      // List&lt;Path&gt; list = Arrays.asList(array);
  
      // This will work but is not particularly pretty
      List&lt;Path&gt; list = new ArrayList&lt;Path&gt;();
      for (int i = 0; i &lt; array.length; i++) {
        list.add(array[i].toPath());
      }
  
      System.out.println(list);
    }
  }
  </code></pre>