Here you can find the source of getFiles(String dir)
public static List<String> getFiles(String dir)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getFiles(String dir) { List<String> files = new ArrayList<>(); File folder = new File(dir); File[] listOfFiles = folder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { files.add(listOfFiles[i].getAbsolutePath()); } else if (listOfFiles[i].isDirectory()) { System.out.println("Directory " + listOfFiles[i].getName()); }// w w w. j a v a 2s . c o m } return files; } }