Advertisement
PasteyMash

Untitled

Jul 1st, 2020
1,215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1.        
  2.         //Getting path of the JSON local response
  3.         String userDirectory = System.getProperty("user.dir");
  4.         File file = new File(userDirectory + "\\src\\main\\resources\\assets\\pizzas.json");
  5.         //Reading the file
  6.         StringBuilder sb =  new StringBuilder();
  7.         JsonReader reader = null;
  8.         try {
  9.             reader = new JsonReader(new FileReader(file));
  10.         } catch (
  11.                 FileNotFoundException e) {
  12.             e.printStackTrace();
  13.         }
  14.         //Desarializing
  15.         List<Deal> list = gson.fromJson(reader,
  16.                 new TypeToken<List<Deal>>(){}.getType());
  17.         return list;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement