java2参考大全上的例子的源码和自己的理解.

源代码在线查看: dirlistonly.java~2~

软件大小: 970 K
上传用户: xingxian
关键词: java2 源码
下载地址: 免注册下载 普通下载 VIP

相关代码

				package filenamefilter接口;
				
				/**
				 1.txt
				 2.txt
				 */
				
				// Directory of .HTML files.
				import java.io.*;
				
				class OnlyExt
				    implements FilenameFilter {
				  String ext;
				
				  public OnlyExt(String ext) {
				    this.ext = "." + ext;
				  }
				
				  public boolean accept(File dir, String name) {
				    return name.endsWith(ext);
				  }
				}
				
				class DirListOnly {
				  public static void main(String args[]) {
				    String dirname = "java";
				    File f1 = new File(dirname);
				    FilenameFilter only = new OnlyExt("txt");
				    String s[] = f1.list(only);
				
				    for (int i = 0; i < s.length; i++) {
				      System.out.println(s[i]);
				    }
				  }
				}
							

相关资源