The directoryReader gets you dirs in current dir in File[]-format.
Code
DirectoryReader data = new DirectoryReader();
File[] dirs = data.getDirsInDir(".");
File[] dirsMore = data.getDirsInDir("..");
// How can I append dirsMore to dirs-file[]?
The directoryReader gets you dirs in current dir in File[]-format.
Code
DirectoryReader data = new DirectoryReader();
File[] dirs = data.getDirsInDir(".");
File[] dirsMore = data.getDirsInDir("..");
// How can I append dirsMore to dirs-file[]?
List<File> aList = Arrays.asList(dirs);
List<File> bList = Arrays.asList(dirsMore);
aList.addAll(bList); // a has all elements
You can't append to an array. The simplest way is to put the array into a Collection, do an "addAll" to the other array, and then use "toArray" on the Collection.
List<File> fileList = new ArrayList<File>();
fileList.addAll(dirs);
fileList.addAll(dirsMore);
File[] allDirs = fileList.toArray(new File[0]);
File[] concat(File[] A, File[] B)
{
File[] C= new File[A.length+B.length];
System.arraycopy(A, 0, C, 0, A.length);
System.arraycopy(B, 0, C, A.length, B.length);
return C;
}
Heres the doc for java's arraycopy() method.