Java实现的文件过滤代码分享(按后辍过滤)
Java实现的文件过滤代码分享(按后辍过滤)
发布时间:2016-12-28 来源:查字典编辑
摘要:好久没有写代码了,也好久没有更新我的博客了,昨晚写了这个过滤文件名的程序,遂发之~/*name:FileNameFilter*author:...

好久没有写代码了,也好久没有更新我的博客了,昨晚写了这个过滤文件名的程序,遂发之~

/*name:FileNameFilter *author : Runzhen Wang *date:2009/11/04 */ import java.util.*; import java.io.*; import java.lang.*; class FileNameFilter{ public void filter(String strPath,String fname){ File f=new File(strPath); String s=new String(); if(f.isDirectory()){ File[] fList =f.listFiles(); for(int i=0;i<fList.length;i++){ if(fList[i].isFile()&&fList[i].getName().endsWith(fname)){ System.out.println(fList[i].getName()); } } } } } public class FileNameFilterDemo{ public static void main(String[] args){ FileNameFilter fnf=new FileNameFilter(); Scanner kb=new Scanner(System.in); String str1=new String(); String str2=new String(); System.out.print(“输入文件目录:”); str1=kb.next(); System.out.print(“输入过滤后缀名:”); str2=kb.next(); fnf.filter(str1,str2); } }

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Java学习
热门Java学习
编程开发子分类