Hello,
Check out this code, I think it can help you.
Code:
Public class CompteurDeFichiersAvecExtensionG
{
Public static void hand( Final String[] args)
{
File fl = null;
File[] prls = null;
String fld = null;
String fil = null;
if ( args.length == 0 ) { fld = "."; Filter = ""; }
else if ( args.length == 1 ) { fld = "."; Filter = args[0]; }
else { fld = args[0]; Filter = args[1]; }
fl = new File(fld);
if (( ! fil.startsWith(".") )&&( args.length != 0 )) fil = "."+ fil;
Final String tmp = fil;
prls = fl.listFiles(new FileFilter()
{
Public boolean accept(File file)
{
if ((file.isDirectory()==false) &&
(file.getName().endsWith(tmp)))
{
/ / Only files are made, not
/ / The directory.
return true;
}
return false;
}
});
for(int i =0; I <prls.length; I + +)
{
String = nomAvecExt prls[i].getName();
int lg = nomAvecExt.length();
String nomSansExt = nomAvecExt.substring(0, Long-fil.length());
System.out.System.out.println(nomSansExt);
}
System.out.System.out.println("\ n > "+ prls.length+"File *"+ + fil"Found.");
}
}
Bookmarks