Note that there are some explanatory texts on larger screens.

plurals
  1. POFile Output between multiple runtimes?
    primarykey
    data
    text
    <p>I am working on this project where the user enters some data which is written to an XML file.This part is working fine. Now when the user runs the program he should be able to append to that file. Instead it creates a new file with just one entry! A fileoutput stream is also not the solution.</p> <p>Here is the code for serializing to XML</p> <pre><code>String medicine=medicfield.getText(); String doctor=dnamefield.getText(); int duration=Integer.parseInt(dodfield.getText()); int amount=Integer.parseInt(cyclefield.getText()); int inter=Integer.parseInt(intval.getText()); PrescripManager pm=new PrescripManager(); pm.setDcycle(amount); pm.setDosage(duration); pm.setInterval(inter); pm.setmedName(medicine); pm.setdocName(doctor); try{ FileOutputStream file = new FileOutputStream("file.xml"); JAXBContext jaxbContext = JAXBContext.newInstance(PrescripManager.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); // output pretty printed jaxbMarshaller.marshal(pm, file); } catch(Exception ex) { erlbl.setText(ex.getMessage()); } </code></pre> <p>And the Class::</p> <pre><code>@XmlRootElement public class PrescripManager { private String medname,docname; private int interval,dcycle,dosage; private Date dt; public String getmedName() { return medname; } public void setmedName(String medname) { this.medname = medname; } public String getdocName() { return docname; } public void setdocName(String docname) { this.docname = docname; } public int getInterval() { return interval; } public void setInterval(int interval) { this.interval = interval; } public int getDcycle() { return dcycle; } public void setDcycle(int dcycle) { this.dcycle = dcycle; } public int getDosage() { return dosage; } public void setDosage(int dosage) { this.dosage = dosage; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload