Skip to content

Instantly share code, notes, and snippets.

@yusufcakal
Created October 4, 2017 18:01
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/1a92caa6c3d196bb03223cd6cc27d4d5 to your computer and use it in GitHub Desktop.
Save yusufcakal/1a92caa6c3d196bb03223cd6cc27d4d5 to your computer and use it in GitHub Desktop.
Medium Post
package main;
import pojo.Job;
import pojo.User;
public class Main {
public static void main(String[] args) {
User user = new User(1,"Yusuf","yusufcakal","123456");
Job job = new Job("Computer Science", "Engineer");
user.setJob(job);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(User.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //Çıktının formatlı olmasını istiyoruz.
marshaller.marshal(user, 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