第七天 如何File操作过滤os下的.exe后缀的的运行程序?

来源:互联网 发布:ubuntu root默认密码 编辑:程序博客网 时间:2024/06/13 00:26
public class Exercise {public static void main(String[] args) {//windows平台的路径都是\形式,java的是/形式File file=new File("c:/windows");FileFilter f1=new FileFilter(){@Overridepublic boolean accept(File pathname) {// TODO Auto-generated method stubreturn pathname.getName().endsWith(".exe")?true:false;}};File[] files=file.listFiles(f1);for(File f2 : files){System.out.println(f2.getAbsolutePath());}}}


 
原创粉丝点击