/** * Compter le nombre de fichiers dans un répertoire. */ import java.io.*; int countFiles (String parent) throws Exception { File file = new File (parent); if (!file.exists ()) throw new FileNotFoundException (); return file.list ().length; }