Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Application
- public static void main(String[] args) {
- SpringApplication.run(ParsingProjApplication.class, args);
- BlockingQueue<String> data = new LinkedBlockingQueue<>();
- ObjectMapper mapper = new ObjectMapper();
- ReadService.readFile("src/main/resources/data.json", data);
- data.parallelStream().forEach(s -> {
- try {
- System.out.println(mapper.readValue(s,Order.class));
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- }
- });
- //ReadingService
- public static void readFile(String fileName, BlockingQueue<String> data) {
- try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
- for (String line; (line = br.readLine()) != null; ) {
- data.add(line);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement