import java.io.*; import java.util.*; public class ChooseWord { /*Fonction pour choisir le mot aléatoirement*/ public static String chooseTheWord() { List words = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new FileReader("motsFacile.txt"))) { String line; while ((line = reader.readLine()) != null) { if (!line.trim().isEmpty()) { words.add(line.trim().toLowerCase()); } } } catch (IOException e) { e.printStackTrace(); } if (words.isEmpty()) { return "default"; } Random rand = new Random(); return words.get(rand.nextInt(words.size())); } }