Advertisement
daegron

ParseProj

Apr 13th, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. //Application
  2. public static void main(String[] args) {
  3.         SpringApplication.run(ParsingProjApplication.class, args);
  4.         BlockingQueue<String> data = new LinkedBlockingQueue<>();
  5.         ObjectMapper mapper = new ObjectMapper();
  6.         ReadService.readFile("src/main/resources/data.json", data);
  7.         data.parallelStream().forEach(s -> {
  8.             try {
  9.                 System.out.println(mapper.readValue(s,Order.class));
  10.             } catch (JsonProcessingException e) {
  11.                 e.printStackTrace();
  12.             }
  13.         });
  14.  
  15. //ReadingService
  16. public static void readFile(String fileName, BlockingQueue<String> data) {
  17.         try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
  18.             for (String line; (line = br.readLine()) != null; ) {
  19.                 data.add(line);
  20.             }
  21.         } catch (IOException e) {
  22.             e.printStackTrace();
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement