49 lines
992 B
Java
49 lines
992 B
Java
package net.altimate.app;
|
|
import java.io.File;
|
|
|
|
import static java.util.regex.Pattern.matches;
|
|
|
|
|
|
public class ListFilesInDir {
|
|
|
|
public String[] listFilesInDir(String directory) {
|
|
|
|
File filesInDir = null;
|
|
File[] paths;
|
|
String match = "^.*.smart$";
|
|
|
|
int count=0;
|
|
int filterArrayLength=0;
|
|
|
|
try {
|
|
filesInDir = new File(directory);
|
|
} catch(Exception efile){
|
|
|
|
efile.printStackTrace();
|
|
}
|
|
|
|
paths = filesInDir.listFiles();
|
|
|
|
for (File path:paths) {
|
|
if (path.getName().matches(match)) {
|
|
filterArrayLength++;
|
|
}
|
|
}
|
|
|
|
String[] filter = new String[filterArrayLength];
|
|
|
|
for (File path:paths) {
|
|
if (path.getName().matches(match)) {
|
|
filter[count] = path.getName();
|
|
count++;
|
|
}
|
|
}
|
|
return filter;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|