#Saving file with marshaller

3 messages · Page 1 of 1 (latest)

abstract cosmos
#

File appears in file system only after I stop the application, but I would like to use the file immediately after saving it. Fix?

@Service
public class XMLTransformationService {

    public void transformToXML(Airlines airlines) {
        JAXBContext jaxbContext = null;
        try {
            jaxbContext = JAXBContext.newInstance(Airlines.class);
            Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
            jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

            File file = new File("src/main/resources/output.xml");
            jaxbMarshaller.marshal(airlines, file);

        } catch (JAXBException e) {
            System.out.println(e.getCause());
        }
    }
}
remote cipherBOT
#

This post has been reserved for your question.

Hey @abstract cosmos! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.