Here you can find the source of getAllFileName(String path)
public static List<String> getAllFileName(String path)
//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> getAllFileName(String path) { File file = new File(path); File[] fileName = file.listFiles(); List<String> list = new ArrayList<>(); if (file.isDirectory()) { for (File string : fileName) if (new File(string.getPath()).isFile()) { System.out.println(string.getPath()); list.add(string.getPath()); }//from w ww . ja v a 2s . c o m } else { System.out.println("it's a file."); //System.exit(1); } return list; } }