public static void main(String args[]) {
File file = new File("C:\\Users\\Administrator\\Desktop\\ship");
FileFilter ff = new FileFilter() {
@Override
public boolean accept(File pathname) {
String s = pathname.getName().toLowerCase();
// if (s.endsWith(".txt")) {
if (s.startsWith("0422191303689")) {
return true;
}
return false;
}
};
File[] flist = file.listFiles(ff);
if (flist == null) {
System.out.println("没有此文件目录");
return;
}
for (File fs : flist) {
// 打印符合条件的所有文件
System.out.println(fs);
}
}
// 删除flv m3u8 ts文件
// 文件目录
File file = new File(rootUrl.substring(0, rootUrl.lastIndexOf("/")));
final String likes = filePath.substring(filePath.lastIndexOf("/") + 1,
filePath.lastIndexOf("."));
FileFilter ff = new FileFilter() {
@Override
public boolean accept(File pathname) {
String s = pathname.getName().toLowerCase();
if (s.startsWith(likes)) {
return true;
}
return false;
}
};
File[] flist = file.listFiles(ff);
if (flist == null) {
System.out.println("没有此文件目录");
return;
}
for (File fs : flist) {
// 打印符合条件的所有文件
System.out.println(fs);
}