diff --git a/src/tp09/ListExecutable.java b/src/tp09/ListExecutable.java new file mode 100644 index 0000000000000000000000000000000000000000..c07e641c7f98234eded68f7c5afda25e191d974c --- /dev/null +++ b/src/tp09/ListExecutable.java @@ -0,0 +1,37 @@ +package tp09; + +import java.io.File; +import java.util.Scanner; + +public class ListExecutable { + public static void printExecutable(File file) { + if (file.exists()) { + if(file.isFile() && !file.isHidden()) { + if(file.canExecute()) { + System.out.println(file.getName()); + } else { + System.out.println("Nothing is executable."); + } + } else { + File[] li = file.listFiles(); + for (File fichier : li) { + if(fichier.isFile() && !file.isHidden()) { + if(fichier.canExecute()) { + System.out.println(fichier.getName()); + } + } + } + } + } else { + System.out.println("File does not exist."); + } + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.print("Veuillez entrer le nom du fichier ou du dossier que vous souhaitez vérifier : "); + File file = new File(scanner.nextLine()); + printExecutable(file); + scanner.close(); + } +} \ No newline at end of file