Here you can find the source of getFiles(String _path)
public static Collection<String> getFiles(String _path)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.Collection; public class Main { public static Collection<String> getFiles(String _path) { Collection<String> files = new ArrayList<String>(); File[] listOfFiles = new File(_path).listFiles(); if (listOfFiles != null) for (File f : listOfFiles) if (f.isFile()) files.add(f.getName()); return files; }//from w w w. j ava 2 s . co m public static Collection<String> getFiles(String _path, String... _ext) { Collection<String> files = new ArrayList<String>(); File[] listOfFiles = new File(_path).listFiles(); if (listOfFiles != null) for (File f : listOfFiles) if (f.isFile()) { String path = f.getAbsolutePath(); String ext = path.substring(path.lastIndexOf(".") + 1); for (String extInc : _ext) if (ext.equalsIgnoreCase(extInc)) files.add(f.getName()); } return files; } }