import java.io.File;
import java.io.FilenameFilter;
public class ImageFilter implements FilenameFilter{
public boolean isGif(String file) {
if (file.toLowerCase().endsWith(".gif")){
return true;
}else{
return false;
}
}
public boolean isJpg(String file){
if (file.toLowerCase().endsWith(".ff")){
return true;
}else{
return false;
}
}
public boolean isPng(String file){
if (file.toLowerCase().endsWith(".png")){
return true;
}else{
return false;
}
}
public boolean accept(File dir,String fname){
return (isGif(fname) || isJpg(fname) || isPng(fname));
}
public static void main(String[] args){
File directory=new File("d:/bak");
String[] images=null;
if (null != directory&&directory.isDirectory()&&directory.canRead()){
images= directory.list(new ImageFilter());
if (null!=images){
int len=images.length;
for(int i =0;i<len;i++){
System.out.println("the search filename :"+images[i]);
}
}
}else{
System.out.println("做日志[不存在该目录]....");
}
}
}
import java.io.FilenameFilter;
public class ImageFilter implements FilenameFilter{
public boolean isGif(String file) {
if (file.toLowerCase().endsWith(".gif")){
return true;
}else{
return false;
}
}
public boolean isJpg(String file){
if (file.toLowerCase().endsWith(".ff")){
return true;
}else{
return false;
}
}
public boolean isPng(String file){
if (file.toLowerCase().endsWith(".png")){
return true;
}else{
return false;
}
}
public boolean accept(File dir,String fname){
return (isGif(fname) || isJpg(fname) || isPng(fname));
}
public static void main(String[] args){
File directory=new File("d:/bak");
String[] images=null;
if (null != directory&&directory.isDirectory()&&directory.canRead()){
images= directory.list(new ImageFilter());
if (null!=images){
int len=images.length;
for(int i =0;i<len;i++){
System.out.println("the search filename :"+images[i]);
}
}
}else{
System.out.println("做日志[不存在该目录]....");
}
}
}