public static void main(String args[]) throws IOException{ List<String> lines = Files.readAllLines(Paths.get("test.txt")); Random r = new Random(); while(!lines.isEmpty()){ String nextLine = lines.get(r.nextInt(lines.size())); System.out.println(nextLine); lines.remove(nextLine); } }