Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.nio.file.Files;
  4. import java.nio.file.Paths;
  5. import java.util.Comparator;
  6. import java.util.stream.Stream;
  7.  
  8. import static java.util.stream.Collectors.joining;
  9.  
  10. public class Pr07ExcellentStudents {
  11.  
  12.     public static void main(String[] args) {
  13.         final String dataFile = "src\\Lesson07BuiltInQueryMethodsStreamAPI\\Resources\\StudentData.txt";
  14.  
  15.         try (BufferedReader br = Files.newBufferedReader(Paths.get(dataFile))) {
  16.             br.lines()
  17.                     .skip(1)
  18.                     .map(line -> line.split("\\s+"))
  19.                     .filter(x -> Stream.of(x[6], x[7], x[8], x[9]).filter("6"::equals).count() >= 1)
  20.                     .forEachOrdered(x -> System.out.printf("%s %s %s%n", x[1], x[2],
  21.                             Stream.of(x[6], x[7], x[8], x[9])
  22.                                     .sorted(Comparator.reverseOrder())
  23.                                     .collect(joining(" ")))
  24.                     );
  25.         } catch (IOException e) {
  26.             e.printStackTrace();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement