List<String> result; try (Stream<String> lines = Files.lines(Paths.get(fileName))) { result = lines.collect(Collectors.toList()); }