Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Group unmarshall() {
- try(InputStream inputStream = new FileInputStream("resources/office_list.xml")) {
- JAXBContext context = JAXBContext.newInstance(Group.class);
- Marshaller marshaller = context.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- //write XML to an array of bytes
- //ByteArrayOutputStream baos = new ByteArrayOutputStream();
- //marshaller.marshal(createJavaObjectExample1(), baos);
- //read XML from array of bytes
- //InputStream bais = new ByteArrayInputStream(baos.toByteArray());
- Unmarshaller unmarshaller = context.createUnmarshaller();
- Object o = unmarshaller.unmarshal(inputStream);
- group = (Group) o;
- //System.out.println(group.getName());
- return group;
- } catch (JAXBException exception) {
- Logger.getLogger(Application.class.getName()).
- log(Level.SEVERE, "saveMarshall threw JAXBException", exception);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement