FileNameFilter interface example

xiaoxiao2021-03-31  217

import java.io *;. public class OnlyExt implements FilenameFilter {String strExt; "." public OnlyExt (String strExt) {this.strExt = strExt;} public boolean accept (File fleDir, String strName) {return strName.endsWith ( strexT);}}

// Directory of .TXT files.import java.io *; class DirListOnly {public static void main (String [] args) {String strDirName =. "C: / winnt"; File f1 = new File (strDirName); FilenameFilter only = New OnLyext ("txt"); string s [] = f1.list (ONLY); for (int i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-130927.html

New Post(0)