Saving file with marshaller

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());
        }
    }
}
Was this page helpful?