I'm wondering, why is there a problem to change Arraylist of File to an array.
public static void main(String[] args) {
List<File> pl = new ArrayList<File>();
pl.add(new File ("C:\\folder"));
String[] k;
k = pl.toArray(new String[pl.size()]);
System.out.println(k);
}
In a simple example above I will get:
Exception in thread "main" java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.ArrayList.toArray(Unknown Source)
at Main.main(Main.java:25)
and second question: Do I have to pass size of Arraylist? Because both version works fine with arraylist of strings:
k = pl.toArray(new String[pl.size()]);
k = pl.toArray(new String[] {});