产看文件目录列表,java小工具

import java.io.*;

class FileName implements FilenameFilter{
String str = null;

FileName(String s){
str = "." + s;
}
public boolean accept(File dir, String name){
return name.endsWith("a");
}
}

public class MyTest {
public static void main (String[] args){
/**
FileOutputStream fos = null;
try{
for(int i=0; i<10; i++){
new FileOutputStream("D:/200/Mytest" + i +

".java");
}
}catch(IOException e){
System.exit(0);
}
*/


File filePath = new File("D:/200");
FileName help = new FileName("java");
System.out.println(filePath.isFile());
String[] fileName = filePath.list(help);
for(int i=0; i<fileName.length; i++){
System.out.println(fileName[i]);
}
}
}

你可能感兴趣的:(java)