Advertisement
xeritt

Untitled

Jul 25th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import com.fasterxml.jackson.databind.ObjectMapper;
  2.  
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.IOException;
  6. import java.util.logging.Level;
  7. import java.util.logging.Logger;
  8.  
  9. public class JacksonSimple {
  10.  
  11. public static void main(String[] args) {
  12. readValue();
  13. }
  14.  
  15. private static void readValue() {
  16. ObjectMapper mapper = new ObjectMapper();
  17. String filepath = System.getProperty("user.dir") + File.separator
  18. + "user.json";
  19. try {
  20. User user = (User) mapper.readValue(new FileInputStream(filepath),
  21. User.class);
  22. System.out.println(user);
  23. } catch (IOException ex) {
  24. Logger.getLogger(JacksonSimple.class.getName())
  25. .log(Level.SEVERE, null, ex);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement