Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 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.  
  6. public class Pr06FilterStudentsByPhone {
  7.  
  8.     public static void main(String[] args) {
  9.         final String dataFile = "src\\Lesson07BuiltInQueryMethodsStreamAPI\\Resources\\StudentData.txt";
  10.  
  11.         try (BufferedReader br = Files.newBufferedReader(Paths.get(dataFile))) {
  12.             br.lines()
  13.                     .skip(1)
  14.                     .map(line -> line.split("\\s+"))
  15.                     .filter(x -> x[10].startsWith("02") || x[10].startsWith("+3592"))
  16.                     .map(x -> x[1] + " " + x[2] + " " + x[10])
  17.                     .forEachOrdered(System.out::println);
  18.         } catch (IOException e) {
  19.             e.printStackTrace();
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement