Here you can find the source of getFileNameList(String path)
public static ArrayList<String> getFileNameList(String path)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.Collections; public class Main { public static ArrayList<String> getFileNameList(String path) { File file = new File(path); File[] tempList = file.listFiles(); ArrayList<Integer> tnames = new ArrayList<Integer>(); ArrayList<String> names = new ArrayList<String>(); for (int i = 0; i < tempList.length; i++) { if (tempList[i].isFile()) { tnames.add(Integer.valueOf(tempList[i].getName())); }//ww w.j a v a 2s. com } Collections.sort(tnames); for (int i = 0; i < tnames.size(); i++) { names.add(tnames.get(i) + ""); } if (names.size() == 0) names.add("-1"); return names; } }