Here you can find the source of list(ArrayList
private static void list(ArrayList<File> list, File file, javax.swing.filechooser.FileFilter filter)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.ArrayList; public class Main { private static void list(ArrayList<File> list, File file, javax.swing.filechooser.FileFilter filter) { if (filter.accept(file)) { list.add(file);//from ww w .j av a 2s. com if (file.isFile()) { return; } } if (file.isDirectory()) { File files[] = file.listFiles(); for (int i = 0; i < files.length; i++) { list(list, files[i], filter); } } } }