import java.util.*;
import java.io.File;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
protected String[] getFileList(String path, String format) {
ArrayList<String> fileList = new ArrayList<String>();
File dir = new File(path);
String[] files = dir.list();
Pattern pattern = Pattern.compile("(\\S+."+ format +")");
Pattern pattern2 = Pattern.compile("."+ format +"");
for(int i=0; i<files.length; i++) {
String[] str = pattern2.split(files[i]);
Matcher matcher = pattern.matcher(files[i]);
if(matcher.matches()) {
System.out.println(files[i] +" :::: "+ str[0]);
fileList.add(str[0]);
} else {
System.out.println("no match :"+files[i]);
}
}
String[] list = new String[fileList.size()];
fileList.toArray(list);
return list;
}