Here you can find the source of getFiles(String InputFilePath)
public static ArrayList<File> getFiles(String InputFilePath) throws Exception
//package com.java2s; //License from project: Apache License import java.io.File; import java.nio.file.FileSystems; import java.nio.file.PathMatcher; import java.nio.file.Paths; import java.util.ArrayList; public class Main { public static ArrayList<File> getFiles(String InputFilePath) throws Exception { ArrayList<File> fileList = new ArrayList<File>(); File dir = null;//from w w w . j a v a 2 s . co m String filePattern = null; InputFilePath.trim(); // Handle unix\URI style path if (InputFilePath.lastIndexOf('/') > 0) { dir = new File((InputFilePath.substring(0, InputFilePath.lastIndexOf('/') + 1) == "" ? "." : InputFilePath.substring(0, InputFilePath.lastIndexOf('/') + 1) + "\\")); filePattern = (InputFilePath.substring(InputFilePath.lastIndexOf('/') + 1)); } // handle windows style path else if (InputFilePath.lastIndexOf('\\') > 0) { dir = new File(InputFilePath.substring(0, InputFilePath.lastIndexOf('\\') + 1)); filePattern = (InputFilePath.substring(InputFilePath.lastIndexOf('\\') + 1)); } // User has asked us to use current working directory else { dir = new File("."); filePattern = InputFilePath; } PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + filePattern); if (!dir.isDirectory()) throw new Exception("Not a directory : \"" + dir.getAbsolutePath() + "\". Build from the pattern : " + InputFilePath); File[] InputfileObj = dir.listFiles(); if (!dir.exists() || InputfileObj == null) return null; for (int i = 0; i < InputfileObj.length; i++) if (matcher.matches(Paths.get(InputfileObj[i].getName()))) { fileList.add(InputfileObj[i]); } return fileList; } }