Skip to content

Instantly share code, notes, and snippets.

@yusufcakal
Created October 4, 2017 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yusufcakal/73230efae2fcd0c7d55ab2ca3d55f4dc to your computer and use it in GitHub Desktop.
Save yusufcakal/73230efae2fcd0c7d55ab2ca3d55f4dc to your computer and use it in GitHub Desktop.
Medium Post
User user = new User(1,"Yusuf","yusufcakal","123456");
Job job = new Job("Computer Science", "Engineer");
user.setJob(job);
User user1 = new User(2,"Fatih","fatihsimsek","123456");
Job job1 = new Job("Computer Science", "Enginerr");
user1.setJob(job1);
List<User> userList = new ArrayList<>();
userList.add(user);
userList.add(user1);
UserListWrapper userListWrapper = new UserListWrapper();
userListWrapper.setUserList(userList);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(UserListWrapper.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //Çıktının formatlı olmasını istiyoruz.
marshaller.marshal(userListWrapper, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment